summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-04-12 09:02:56 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-04-12 09:02:56 +0000
commit3842b654030cfbc590936f0836b3c380aebf4442 (patch)
tree73c3c6073b7d753408607cc48e8c9369eb353538
parentd59f48987baceb25aa87dc6d87551f68af4bb1ed (diff)
parentf1f9578f1c95ca6fb60d45b60ace42638980adb5 (diff)
downloadgitlab-ce-3842b654030cfbc590936f0836b3c380aebf4442.tar.gz
Merge branch '30457-expire-note-destroy' into 'master'
Fix issue's note cache expiration after delete Closes #30457 See merge request !10461
-rw-r--r--app/models/note.rb1
-rw-r--r--changelogs/unreleased/30457-expire-note-destroy.yml4
-rw-r--r--spec/models/note_spec.rb12
3 files changed, 16 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index c85692c5aec..630d0adbece 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -96,6 +96,7 @@ class Note < ActiveRecord::Base
before_validation :set_discussion_id, on: :create
after_save :keep_around_commit, unless: :for_personal_snippet?
after_save :expire_etag_cache
+ after_destroy :expire_etag_cache
class << self
def model_name
diff --git a/changelogs/unreleased/30457-expire-note-destroy.yml b/changelogs/unreleased/30457-expire-note-destroy.yml
new file mode 100644
index 00000000000..f5c89da68a9
--- /dev/null
+++ b/changelogs/unreleased/30457-expire-note-destroy.yml
@@ -0,0 +1,4 @@
+---
+title: Fix issue's note cache expiration after delete
+merge_request:
+author: mhasbini
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 3c4bf3f4ddb..557ea97b008 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -622,12 +622,22 @@ describe Note, models: true do
describe 'expiring ETag cache' do
let(:note) { build(:note_on_issue) }
- it "expires cache for note's issue when note is saved" do
+ def expect_expiration(note)
expect_any_instance_of(Gitlab::EtagCaching::Store)
.to receive(:touch)
.with("/#{note.project.namespace.to_param}/#{note.project.to_param}/noteable/issue/#{note.noteable.id}/notes")
+ end
+
+ it "expires cache for note's issue when note is saved" do
+ expect_expiration(note)
note.save!
end
+
+ it "expires cache for note's issue when note is destroyed" do
+ expect_expiration(note)
+
+ note.destroy!
+ end
end
end