Merge branch 'ce-1979-2-1' into 'master'
Add query method for id See merge request gitlab-org/gitlab-ce!24386
This commit is contained in:
commit
49c12f9b0f
4 changed files with 19 additions and 2 deletions
|
@ -2,4 +2,8 @@
|
|||
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
|
||||
def self.id_in(ids)
|
||||
where(id: ids)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Namespace < ActiveRecord::Base
|
||||
class Namespace < ApplicationRecord
|
||||
include CacheMarkdownField
|
||||
include Sortable
|
||||
include Gitlab::VisibilityLevel
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'carrierwave/orm/activerecord'
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
class User < ApplicationRecord
|
||||
extend Gitlab::ConfigHelper
|
||||
|
||||
include Gitlab::ConfigHelper
|
||||
|
|
13
spec/models/application_record_spec.rb
Normal file
13
spec/models/application_record_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe ApplicationRecord do
|
||||
describe '#id_in' do
|
||||
let(:records) { create_list(:user, 3) }
|
||||
|
||||
it 'returns records of the ids' do
|
||||
expect(User.id_in(records.last(2).map(&:id))).to eq(records.last(2))
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue