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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
f7cd5fd7
Commit
f7cd5fd7
authored
Feb 22, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure mutable uploads are not cached without revalidation
parent
29b59456
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
+88
-0
app/controllers/uploads_controller.rb
app/controllers/uploads_controller.rb
+2
-0
changelogs/unreleased/27936-make-all-uploads-require-revalidation-on-each-browser-fetch.yml
...ll-uploads-require-revalidation-on-each-browser-fetch.yml
+4
-0
spec/controllers/uploads_controller_spec.rb
spec/controllers/uploads_controller_spec.rb
+82
-0
No files found.
app/controllers/uploads_controller.rb
View file @
f7cd5fd7
...
...
@@ -14,6 +14,8 @@ class UploadsController < ApplicationController
end
disposition
=
uploader
.
image?
?
'inline'
:
'attachment'
expires_in
0
.
seconds
,
must_revalidate:
true
,
private:
true
send_file
uploader
.
file
.
path
,
disposition:
disposition
end
...
...
changelogs/unreleased/27936-make-all-uploads-require-revalidation-on-each-browser-fetch.yml
0 → 100644
View file @
f7cd5fd7
---
title
:
Uploaded files which content can change now require revalidation on each page load
merge_request
:
9453
author
:
spec/controllers/uploads_controller_spec.rb
View file @
f7cd5fd7
require
'spec_helper'
shared_examples
'content not cached without revalidation'
do
it
'ensures content will not be cached without revalidation'
do
expect
(
subject
[
'Cache-Control'
]).
to
eq
(
'max-age=0, private, must-revalidate'
)
end
end
describe
UploadsController
do
let!
(
:user
)
{
create
(
:user
,
avatar:
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"image/png"
))
}
...
...
@@ -50,6 +55,13 @@ describe UploadsController do
expect
(
response
).
to
have_http_status
(
200
)
end
it_behaves_like
'content not cached without revalidation'
do
subject
do
get
:show
,
model:
'user'
,
mounted_as:
'avatar'
,
id:
user
.
id
,
filename:
'image.png'
response
end
end
end
end
...
...
@@ -59,6 +71,13 @@ describe UploadsController do
expect
(
response
).
to
have_http_status
(
200
)
end
it_behaves_like
'content not cached without revalidation'
do
subject
do
get
:show
,
model:
'user'
,
mounted_as:
'avatar'
,
id:
user
.
id
,
filename:
'image.png'
response
end
end
end
end
...
...
@@ -76,6 +95,13 @@ describe UploadsController do
expect
(
response
).
to
have_http_status
(
200
)
end
it_behaves_like
'content not cached without revalidation'
do
subject
do
get
:show
,
model:
'project'
,
mounted_as:
'avatar'
,
id:
project
.
id
,
filename:
'image.png'
response
end
end
end
context
"when signed in"
do
...
...
@@ -88,6 +114,13 @@ describe UploadsController do
expect
(
response
).
to
have_http_status
(
200
)
end
it_behaves_like
'content not cached without revalidation'
do
subject
do
get
:show
,
model:
'project'
,
mounted_as:
'avatar'
,
id:
project
.
id
,
filename:
'image.png'
response
end
end
end
end
...
...
@@ -133,6 +166,13 @@ describe UploadsController do
expect
(
response
).
to
have_http_status
(
200
)
end
it_behaves_like
'content not cached without revalidation'
do
subject
do
get
:show
,
model:
'project'
,
mounted_as:
'avatar'
,
id:
project
.
id
,
filename:
'image.png'
response
end
end
end
end
...
...
@@ -157,6 +197,13 @@ describe UploadsController do
expect
(
response
).
to
have_http_status
(
200
)
end
it_behaves_like
'content not cached without revalidation'
do
subject
do
get
:show
,
model:
'group'
,
mounted_as:
'avatar'
,
id:
group
.
id
,
filename:
'image.png'
response
end
end
end
context
"when signed in"
do
...
...
@@ -169,6 +216,13 @@ describe UploadsController do
expect
(
response
).
to
have_http_status
(
200
)
end
it_behaves_like
'content not cached without revalidation'
do
subject
do
get
:show
,
model:
'group'
,
mounted_as:
'avatar'
,
id:
group
.
id
,
filename:
'image.png'
response
end
end
end
end
...
...
@@ -205,6 +259,13 @@ describe UploadsController do
expect
(
response
).
to
have_http_status
(
200
)
end
it_behaves_like
'content not cached without revalidation'
do
subject
do
get
:show
,
model:
'group'
,
mounted_as:
'avatar'
,
id:
group
.
id
,
filename:
'image.png'
response
end
end
end
end
...
...
@@ -234,6 +295,13 @@ describe UploadsController do
expect
(
response
).
to
have_http_status
(
200
)
end
it_behaves_like
'content not cached without revalidation'
do
subject
do
get
:show
,
model:
'note'
,
mounted_as:
'attachment'
,
id:
note
.
id
,
filename:
'image.png'
response
end
end
end
context
"when signed in"
do
...
...
@@ -246,6 +314,13 @@ describe UploadsController do
expect
(
response
).
to
have_http_status
(
200
)
end
it_behaves_like
'content not cached without revalidation'
do
subject
do
get
:show
,
model:
'note'
,
mounted_as:
'attachment'
,
id:
note
.
id
,
filename:
'image.png'
response
end
end
end
end
...
...
@@ -291,6 +366,13 @@ describe UploadsController do
expect
(
response
).
to
have_http_status
(
200
)
end
it_behaves_like
'content not cached without revalidation'
do
subject
do
get
:show
,
model:
'note'
,
mounted_as:
'attachment'
,
id:
note
.
id
,
filename:
'image.png'
response
end
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