Fix Lint/ConstantDefinitionInBlock cop (#24763)
This commit is contained in:
parent
8b636a29c6
commit
3df665fd23
9 changed files with 120 additions and 118 deletions
|
@ -223,14 +223,16 @@ describe ApplicationController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'cache_collection' do
|
||||
class C < ApplicationController
|
||||
public :cache_collection
|
||||
subject do
|
||||
Class.new(ApplicationController) do
|
||||
public :cache_collection
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'receives :with_includes' do |fabricator, klass|
|
||||
it 'uses raw if it is not an ActiveRecord::Relation' do
|
||||
record = Fabricate(fabricator)
|
||||
expect(C.new.cache_collection([record], klass)).to eq [record]
|
||||
expect(subject.new.cache_collection([record], klass)).to eq [record]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -241,13 +243,13 @@ describe ApplicationController, type: :controller do
|
|||
record = Fabricate(fabricator)
|
||||
relation = klass.none
|
||||
allow(relation).to receive(:cache_ids).and_return([record])
|
||||
expect(C.new.cache_collection(relation, klass)).to eq [record]
|
||||
expect(subject.new.cache_collection(relation, klass)).to eq [record]
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns raw unless class responds to :with_includes' do
|
||||
raw = Object.new
|
||||
expect(C.new.cache_collection(raw, Object)).to eq raw
|
||||
expect(subject.new.cache_collection(raw, Object)).to eq raw
|
||||
end
|
||||
|
||||
context 'Status' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue