0
0
Fork 0

Remove caching in cache_collection (#29862)

This commit is contained in:
Claire 2024-04-08 15:46:13 +02:00 committed by GitHub
parent f3430eebbb
commit babbf6017d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 14 additions and 86 deletions

View file

@ -218,39 +218,4 @@ describe ApplicationController do
include_examples 'respond_with_error', 422
end
describe 'cache_collection' do
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(subject.new.cache_collection([record], klass)).to eq [record]
end
end
shared_examples 'cacheable' do |fabricator, klass|
include_examples 'receives :with_includes', fabricator, klass
it 'calls cache_ids of raw if it is an ActiveRecord::Relation' do
record = Fabricate(fabricator)
relation = klass.none
allow(relation).to receive(:cache_ids).and_return([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(subject.new.cache_collection(raw, Object)).to eq raw
end
context 'with a Status' do
include_examples 'cacheable', :status, Status
end
end
end