Skip to content
Snippets Groups Projects
Commit d253440e authored by Mark Chao's avatar Mark Chao
Browse files

Add query method for id query

parent 2abbfda3
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2,4 +2,8 @@
 
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
def self.id_in(ids)
where(id: ids)
end
end
# frozen_string_literal: true
 
class Namespace < ActiveRecord::Base
class Namespace < ApplicationRecord
include CacheMarkdownField
include Sortable
include Gitlab::VisibilityLevel
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
 
require 'carrierwave/orm/activerecord'
 
class User < ActiveRecord::Base
class User < ApplicationRecord
extend Gitlab::ConfigHelper
 
include Gitlab::ConfigHelper
Loading
Loading
# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment