diff options
author | Sean McGivern <sean@gitlab.com> | 2017-07-17 21:36:29 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2017-07-21 22:35:26 +0300 |
commit | db0b7fb39e921728385b3287d206aabbeb88690e (patch) | |
tree | d2c1f43d192ce30cf3185cf104ec2ffcf1d02704 /spec/models/award_emoji_spec.rb | |
parent | aed5632ca4d848ebc1e0cfed3465807cf36afe9e (diff) |
Expire ETag cache on note when award emoji changes
Diffstat (limited to 'spec/models/award_emoji_spec.rb')
-rw-r--r-- | spec/models/award_emoji_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/award_emoji_spec.rb b/spec/models/award_emoji_spec.rb index 2a9a27752c1..2925fc1271c 100644 --- a/spec/models/award_emoji_spec.rb +++ b/spec/models/award_emoji_spec.rb @@ -41,4 +41,40 @@ describe AwardEmoji, models: true do end end end + + describe 'expiring ETag cache' do + context 'on a note' do + let(:note) { create(:note_on_issue) } + let(:award_emoji) { build(:award_emoji, user: build(:user), awardable: note) } + + it 'calls expire_etag_cache on the note when saved' do + expect(note).to receive(:expire_etag_cache) + + award_emoji.save! + end + + it 'calls expire_etag_cache on the note when destroyed' do + expect(note).to receive(:expire_etag_cache) + + award_emoji.destroy! + end + end + + context 'on another awardable' do + let(:issue) { create(:issue) } + let(:award_emoji) { build(:award_emoji, user: build(:user), awardable: issue) } + + it 'does not call expire_etag_cache on the issue when saved' do + expect(issue).not_to receive(:expire_etag_cache) + + award_emoji.save! + end + + it 'does not call expire_etag_cache on the issue when destroyed' do + expect(issue).not_to receive(:expire_etag_cache) + + award_emoji.destroy! + end + end + end end |