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
256d9597
Commit
256d9597
authored
Apr 12, 2018
by
Alexis Reigel
Committed by
Alexis Reigel
Jun 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ability to get an image's alternative version
parent
46328b12
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
app/controllers/concerns/uploads_actions.rb
app/controllers/concerns/uploads_actions.rb
+7
-1
spec/controllers/uploads_controller_spec.rb
spec/controllers/uploads_controller_spec.rb
+22
-0
No files found.
app/controllers/concerns/uploads_actions.rb
View file @
256d9597
...
@@ -31,7 +31,13 @@ module UploadsActions
...
@@ -31,7 +31,13 @@ module UploadsActions
disposition
=
uploader
.
image_or_video?
?
'inline'
:
'attachment'
disposition
=
uploader
.
image_or_video?
?
'inline'
:
'attachment'
send_upload
(
uploader
,
attachment:
uploader
.
filename
,
disposition:
disposition
)
uploader_version
=
uploader
.
versions
.
values
.
find
{
|
version
|
version
.
filename
==
params
[
:filename
]
}
if
uploader_version
return
send_upload
(
uploader_version
,
attachment:
uploader_version
.
filename
,
disposition:
disposition
)
end
return
send_upload
(
uploader
,
attachment:
uploader
.
filename
,
disposition:
disposition
)
end
end
private
private
...
...
spec/controllers/uploads_controller_spec.rb
View file @
256d9597
...
@@ -560,5 +560,27 @@ describe UploadsController do
...
@@ -560,5 +560,27 @@ describe UploadsController do
end
end
end
end
end
end
context
'the version filename must match'
do
let!
(
:appearance
)
{
create
:appearance
,
favicon:
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/dk.png'
),
'image/png'
)
}
context
'has a valid filename on the version file'
do
it
'successfully returns the file'
do
get
:show
,
model:
'appearance'
,
mounted_as:
'favicon'
,
id:
appearance
.
id
,
filename:
'favicon_main_dk.png'
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
.
header
[
'Content-Disposition'
]).
to
eq
'inline; filename="favicon_main_dk.png"'
end
end
context
'has an invalid filename on the version file'
do
it
'returns the original file'
do
get
:show
,
model:
'appearance'
,
mounted_as:
'favicon'
,
id:
appearance
.
id
,
filename:
'favicon_bogusversion_dk.png'
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
.
header
[
'Content-Disposition'
]).
to
eq
'inline; filename="dk.png"'
end
end
end
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