Set 2 weeks as the expiration time for the current broadcast message

This commit is contained in:
Douglas Barbosa Alexandre 2019-06-25 19:41:05 -03:00
parent 87b468c254
commit da2f451f95
No known key found for this signature in database
GPG key ID: 4DC4A918C347CAC9
2 changed files with 4 additions and 4 deletions

View file

@ -45,7 +45,7 @@ class BroadcastMessage < ApplicationRecord
end end
def self.cache_expires_in def self.cache_expires_in
nil 2.weeks
end end
def active? def active?

View file

@ -48,14 +48,14 @@ describe BroadcastMessage do
expect(described_class.current).to be_empty expect(described_class.current).to be_empty
end end
it 'caches the output of the query' do it 'caches the output of the query for two weeks' do
create(:broadcast_message) create(:broadcast_message)
expect(described_class).to receive(:current_and_future_messages).and_call_original.once expect(described_class).to receive(:current_and_future_messages).and_call_original.twice
described_class.current described_class.current
Timecop.travel(1.year) do Timecop.travel(3.weeks) do
described_class.current described_class.current
end end
end end