Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c661df35
Commit
c661df35
authored
Feb 08, 2017
by
Adam Niedzielski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Invalidate ETag cache when note changes
parent
61c96047
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
app/models/note.rb
app/models/note.rb
+13
-0
spec/models/note_spec.rb
spec/models/note_spec.rb
+12
-0
No files found.
app/models/note.rb
View file @
c661df35
...
...
@@ -85,6 +85,7 @@ class Note < ActiveRecord::Base
before_validation
:nullify_blank_type
,
:nullify_blank_line_code
before_validation
:set_discussion_id
after_save
:keep_around_commit
,
unless: :for_personal_snippet?
after_save
:expire_etag_cache
class
<<
self
def
model_name
...
...
@@ -272,4 +273,16 @@ class Note < ActiveRecord::Base
self
.
class
.
build_discussion_id
(
noteable_type
,
noteable_id
||
commit_id
)
end
end
def
expire_etag_cache
return
unless
for_issue?
key
=
Gitlab
::
Routing
.
url_helpers
.
namespace_project_noteable_notes_path
(
noteable
.
project
.
namespace
,
noteable
.
project
,
target_type:
noteable_type
.
underscore
,
target_id:
noteable
.
id
)
Gitlab
::
EtagCaching
::
Store
.
new
.
touch
(
key
)
end
end
spec/models/note_spec.rb
View file @
c661df35
...
...
@@ -387,4 +387,16 @@ describe Note, models: true do
end
end
end
describe
'expiring ETag cache'
do
let
(
:note
)
{
build
(
:note_on_issue
)
}
it
"expires cache for note's issue when note is saved"
do
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"
)
note
.
save!
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment