Merge branch '30457-expire-note-destroy' into 'master'
Fix issue's note cache expiration after delete Closes #30457 See merge request !10461
This commit is contained in:
		
						commit
						3842b65403
					
				|  | @ -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 | ||||
|  |  | |||
|  | @ -0,0 +1,4 @@ | |||
| --- | ||||
| title: Fix issue's note cache expiration after delete | ||||
| merge_request: | ||||
| author: mhasbini | ||||
|  | @ -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 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue