summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormhasbini <mohammad.hasbini@gmail.com>2017-04-11 15:20:25 +0300
committermhasbini <mohammad.hasbini@gmail.com>2017-04-11 15:20:25 +0300
commitf1f9578f1c95ca6fb60d45b60ace42638980adb5 (patch)
tree14b37f0793dfc145d9ec4bd594d3237283bcadda
parent9c576cc7e9414e64b4aac0544615e7d5e92c3558 (diff)
downloadgitlab-ce-f1f9578f1c95ca6fb60d45b60ace42638980adb5.tar.gz
Fix issue's note cache expiration after delete
-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 1ea7b946061..834507feccc 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