2018-02-08 22:44:39 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-02-09 18:49:25 +00:00
|
|
|
RSpec.describe Rating::Extension, 'after_create' do
|
2018-02-08 22:44:39 +00:00
|
|
|
context 'when record is author' do
|
|
|
|
let!(:record) { build :author }
|
|
|
|
|
2018-02-09 18:49:25 +00:00
|
|
|
it 'does not warm up the cache' do
|
2018-02-08 22:44:39 +00:00
|
|
|
expect(record).not_to receive(:rating_warm_up)
|
|
|
|
|
|
|
|
record.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when record is not author' do
|
|
|
|
context 'when record has scoping' do
|
|
|
|
let!(:record) { build :article }
|
|
|
|
|
|
|
|
it 'warms up the cache' do
|
|
|
|
expect(record).to receive(:rating_warm_up).with(scoping: :categories)
|
|
|
|
|
|
|
|
record.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when record has no scoping' do
|
|
|
|
let!(:record) { build :comment }
|
|
|
|
|
|
|
|
it 'warms up the cache' do
|
|
|
|
expect(record).to receive(:rating_warm_up).with(scoping: nil)
|
|
|
|
|
|
|
|
record.save
|
|
|
|
end
|
|
|
|
end
|
2018-02-09 18:49:25 +00:00
|
|
|
|
|
|
|
context 'when update is made' do
|
|
|
|
let!(:record) { create :comment }
|
|
|
|
|
|
|
|
it 'does not warm up the cache' do
|
|
|
|
expect(record).not_to receive(:rating_warm_up)
|
|
|
|
|
|
|
|
record.save
|
|
|
|
end
|
|
|
|
end
|
2018-02-08 22:44:39 +00:00
|
|
|
end
|
|
|
|
end
|