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
a75a63cf
Commit
a75a63cf
authored
Jan 22, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
f9719fa3
7363428c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
app/controllers/concerns/uploads_actions.rb
app/controllers/concerns/uploads_actions.rb
+11
-1
app/controllers/uploads_controller.rb
app/controllers/uploads_controller.rb
+4
-0
spec/controllers/uploads_controller_spec.rb
spec/controllers/uploads_controller_spec.rb
+10
-4
No files found.
app/controllers/concerns/uploads_actions.rb
View file @
a75a63cf
...
...
@@ -29,7 +29,13 @@ module UploadsActions
def
show
return
render_404
unless
uploader
&
.
exists?
if
cache_publicly?
# We need to reset caching from the applications controller to get rid of the no-store value
headers
[
'Cache-Control'
]
=
''
expires_in
5
.
minutes
,
public:
true
,
must_revalidate:
false
else
expires_in
0
.
seconds
,
must_revalidate:
true
,
private:
true
end
disposition
=
uploader
.
image_or_video?
?
'inline'
:
'attachment'
...
...
@@ -114,6 +120,10 @@ module UploadsActions
nil
end
def
cache_publicly?
false
end
def
model
strong_memoize
(
:model
)
{
find_model
}
end
...
...
app/controllers/uploads_controller.rb
View file @
a75a63cf
...
...
@@ -70,6 +70,10 @@ class UploadsController < ApplicationController
end
end
def
cache_publicly?
User
===
model
||
Appearance
===
model
end
def
upload_model_class
MODEL_CLASSES
[
params
[
:model
]]
||
raise
(
UnknownUploadModelError
)
end
...
...
spec/controllers/uploads_controller_spec.rb
View file @
a75a63cf
...
...
@@ -12,6 +12,12 @@ shared_examples 'content not cached without revalidation and no-store' do
end
end
shared_examples
'content publicly cached'
do
it
'ensures content is publicly cached'
do
expect
(
subject
[
'Cache-Control'
]).
to
eq
(
'max-age=300, public'
)
end
end
describe
UploadsController
do
let!
(
:user
)
{
create
(
:user
,
avatar:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
))
}
...
...
@@ -184,7 +190,7 @@ describe UploadsController do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it_behaves_like
'content
not cached without revalidation and no-store
'
do
it_behaves_like
'content
publicly cached
'
do
subject
do
get
:show
,
params:
{
model:
'user'
,
mounted_as:
'avatar'
,
id:
user
.
id
,
filename:
'dk.png'
}
...
...
@@ -201,7 +207,7 @@ describe UploadsController do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it_behaves_like
'content
not cached without revalidation
'
do
it_behaves_like
'content
publicly cached
'
do
subject
do
get
:show
,
params:
{
model:
'user'
,
mounted_as:
'avatar'
,
id:
user
.
id
,
filename:
'dk.png'
}
...
...
@@ -537,7 +543,7 @@ describe UploadsController do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it_behaves_like
'content
not cached without revalidation
'
do
it_behaves_like
'content
publicly cached
'
do
subject
do
get
:show
,
params:
{
model:
'appearance'
,
mounted_as:
'header_logo'
,
id:
appearance
.
id
,
filename:
'dk.png'
}
...
...
@@ -557,7 +563,7 @@ describe UploadsController do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it_behaves_like
'content
not cached without revalidation
'
do
it_behaves_like
'content
publicly cached
'
do
subject
do
get
:show
,
params:
{
model:
'appearance'
,
mounted_as:
'logo'
,
id:
appearance
.
id
,
filename:
'dk.png'
}
...
...
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