Fix Lint/ConstantDefinitionInBlock cop (#24763)

This commit is contained in:
Matt Jankowski authored and GitHub committed 2023-05-03 10:32:30 +02:00
1 parent 8b636a29c6
commit 3df665fd23
9 files changed
+120 -118

No files matched your search

@@ -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