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
Léo-Paul Géneau
gitlab-ce
Commits
180de2d2
Commit
180de2d2
authored
Aug 07, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure uploads for personal snippets are correctly rendered
parent
b8ae1539
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
22 additions
and
22 deletions
+22
-22
app/uploaders/personal_file_uploader.rb
app/uploaders/personal_file_uploader.rb
+1
-1
config/routes/uploads.rb
config/routes/uploads.rb
+2
-2
spec/controllers/snippets_controller_spec.rb
spec/controllers/snippets_controller_spec.rb
+4
-4
spec/controllers/uploads_controller_spec.rb
spec/controllers/uploads_controller_spec.rb
+2
-2
spec/features/snippets/user_creates_snippet_spec.rb
spec/features/snippets/user_creates_snippet_spec.rb
+3
-3
spec/features/snippets/user_edits_snippet_spec.rb
spec/features/snippets/user_edits_snippet_spec.rb
+1
-1
spec/uploaders/file_mover_spec.rb
spec/uploaders/file_mover_spec.rb
+7
-7
spec/uploaders/personal_file_uploader_spec.rb
spec/uploaders/personal_file_uploader_spec.rb
+2
-2
No files found.
app/uploaders/personal_file_uploader.rb
View file @
180de2d2
...
...
@@ -4,7 +4,7 @@ class PersonalFileUploader < FileUploader
end
def
self
.
base_dir
File
.
join
(
root_dir
,
'system'
)
File
.
join
(
root_dir
,
'
-'
,
'
system'
)
end
private
...
...
config/routes/uploads.rb
View file @
180de2d2
...
...
@@ -5,12 +5,12 @@ scope path: :uploads do
constraints:
{
model:
/note|user|group|project/
,
mounted_as:
/avatar|attachment/
,
filename:
/[^\/]+/
}
# show uploads for models, snippets (notes) available for now
get
'system/:model/:id/:secret/:filename'
,
get
'
-/
system/:model/:id/:secret/:filename'
,
to:
'uploads#show'
,
constraints:
{
model:
/personal_snippet/
,
id:
/\d+/
,
filename:
/[^\/]+/
}
# show temporary uploads
get
'system/temp/:secret/:filename'
,
get
'
-/
system/temp/:secret/:filename'
,
to:
'uploads#show'
,
constraints:
{
filename:
/[^\/]+/
}
...
...
spec/controllers/snippets_controller_spec.rb
View file @
180de2d2
...
...
@@ -186,8 +186,8 @@ describe SnippetsController do
end
context
'when the snippet description contains a file'
do
let
(
:picture_file
)
{
'/system/temp/secret56/picture.jpg'
}
let
(
:text_file
)
{
'/system/temp/secret78/text.txt'
}
let
(
:picture_file
)
{
'/
-/
system/temp/secret56/picture.jpg'
}
let
(
:text_file
)
{
'/
-/
system/temp/secret78/text.txt'
}
let
(
:description
)
do
"Description with picture: ![picture](/uploads
#{
picture_file
}
) and "
\
"text: [text.txt](/uploads
#{
text_file
}
)"
...
...
@@ -208,8 +208,8 @@ describe SnippetsController do
snippet
=
subject
expected_description
=
"Description with picture: "
\
"![picture](/uploads/system/personal_snippet/
#{
snippet
.
id
}
/secret56/picture.jpg) and "
\
"text: [text.txt](/uploads/system/personal_snippet/
#{
snippet
.
id
}
/secret78/text.txt)"
"![picture](/uploads/
-/
system/personal_snippet/
#{
snippet
.
id
}
/secret56/picture.jpg) and "
\
"text: [text.txt](/uploads/
-/
system/personal_snippet/
#{
snippet
.
id
}
/secret78/text.txt)"
expect
(
snippet
.
description
).
to
eq
(
expected_description
)
end
...
...
spec/controllers/uploads_controller_spec.rb
View file @
180de2d2
...
...
@@ -102,7 +102,7 @@ describe UploadsController do
subject
expect
(
response
.
body
).
to
match
'\"alt\":\"rails_sample\"'
expect
(
response
.
body
).
to
match
"
\"
url
\"
:
\"
/uploads/system/temp"
expect
(
response
.
body
).
to
match
"
\"
url
\"
:
\"
/uploads/
-/
system/temp"
end
it
'does not create an Upload record'
do
...
...
@@ -119,7 +119,7 @@ describe UploadsController do
subject
expect
(
response
.
body
).
to
match
'\"alt\":\"doc_sample.txt\"'
expect
(
response
.
body
).
to
match
"
\"
url
\"
:
\"
/uploads/system/temp"
expect
(
response
.
body
).
to
match
"
\"
url
\"
:
\"
/uploads/
-/
system/temp"
end
it
'does not create an Upload record'
do
...
...
spec/features/snippets/user_creates_snippet_spec.rb
View file @
180de2d2
...
...
@@ -41,7 +41,7 @@ feature 'User creates snippet', :js do
expect
(
page
).
to
have_content
(
'My Snippet'
)
link
=
find
(
'a.no-attachment-icon img[alt="banana_sample"]'
)[
'src'
]
expect
(
link
).
to
match
(
%r{/uploads/system/temp/
\h
{32}/banana_sample
\.
gif
\z
}
)
expect
(
link
).
to
match
(
%r{/uploads/
-/
system/temp/
\h
{32}/banana_sample
\.
gif
\z
}
)
visit
(
link
)
expect
(
page
.
status_code
).
to
eq
(
200
)
...
...
@@ -59,7 +59,7 @@ feature 'User creates snippet', :js do
wait_for_requests
link
=
find
(
'a.no-attachment-icon img[alt="banana_sample"]'
)[
'src'
]
expect
(
link
).
to
match
(
%r{/uploads/system/personal_snippet/
#{
Snippet
.
last
.
id
}
/
\h
{32}/banana_sample
\.
gif
\z
}
)
expect
(
link
).
to
match
(
%r{/uploads/
-/
system/personal_snippet/
#{
Snippet
.
last
.
id
}
/
\h
{32}/banana_sample
\.
gif
\z
}
)
visit
(
link
)
expect
(
page
.
status_code
).
to
eq
(
200
)
...
...
@@ -84,7 +84,7 @@ feature 'User creates snippet', :js do
end
expect
(
page
).
to
have_content
(
'Hello World!'
)
link
=
find
(
'a.no-attachment-icon img[alt="banana_sample"]'
)[
'src'
]
expect
(
link
).
to
match
(
%r{/uploads/system/personal_snippet/
#{
Snippet
.
last
.
id
}
/
\h
{32}/banana_sample
\.
gif
\z
}
)
expect
(
link
).
to
match
(
%r{/uploads/
-/
system/personal_snippet/
#{
Snippet
.
last
.
id
}
/
\h
{32}/banana_sample
\.
gif
\z
}
)
visit
(
link
)
expect
(
page
.
status_code
).
to
eq
(
200
)
...
...
spec/features/snippets/user_edits_snippet_spec.rb
View file @
180de2d2
...
...
@@ -33,7 +33,7 @@ feature 'User edits snippet', :js do
wait_for_requests
link
=
find
(
'a.no-attachment-icon img[alt="banana_sample"]'
)[
'src'
]
expect
(
link
).
to
match
(
%r{/uploads/system/personal_snippet/
#{
snippet
.
id
}
/
\h
{32}/banana_sample
\.
gif
\z
}
)
expect
(
link
).
to
match
(
%r{/uploads/
-/
system/personal_snippet/
#{
snippet
.
id
}
/
\h
{32}/banana_sample
\.
gif
\z
}
)
end
it
'updates the snippet to make it internal'
do
...
...
spec/uploaders/file_mover_spec.rb
View file @
180de2d2
...
...
@@ -4,11 +4,11 @@ describe FileMover do
let
(
:filename
)
{
'banana_sample.gif'
}
let
(
:file
)
{
fixture_file_upload
(
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
filename
))
}
let
(
:temp_description
)
do
'test ![banana_sample](/uploads/system/temp/secret55/banana_sample.gif) same ![banana_sample]'
\
'(/uploads/system/temp/secret55/banana_sample.gif)'
'test ![banana_sample](/uploads/
-/
system/temp/secret55/banana_sample.gif) same ![banana_sample]'
\
'(/uploads/
-/
system/temp/secret55/banana_sample.gif)'
end
let
(
:temp_file_path
)
{
File
.
join
(
'secret55'
,
filename
).
to_s
}
let
(
:file_path
)
{
File
.
join
(
'uploads'
,
'system'
,
'personal_snippet'
,
snippet
.
id
.
to_s
,
'secret55'
,
filename
).
to_s
}
let
(
:file_path
)
{
File
.
join
(
'uploads'
,
'
-'
,
'
system'
,
'personal_snippet'
,
snippet
.
id
.
to_s
,
'secret55'
,
filename
).
to_s
}
let
(
:snippet
)
{
create
(
:personal_snippet
,
description:
temp_description
)
}
...
...
@@ -28,8 +28,8 @@ describe FileMover do
expect
(
snippet
.
reload
.
description
)
.
to
eq
(
"test ![banana_sample](/uploads/system/personal_snippet/
#{
snippet
.
id
}
/secret55/banana_sample.gif)"
\
" same ![banana_sample](/uploads/system/personal_snippet/
#{
snippet
.
id
}
/secret55/banana_sample.gif)"
"test ![banana_sample](/uploads/
-/
system/personal_snippet/
#{
snippet
.
id
}
/secret55/banana_sample.gif)"
\
" same ![banana_sample](/uploads/
-/
system/personal_snippet/
#{
snippet
.
id
}
/secret55/banana_sample.gif)"
)
end
...
...
@@ -50,8 +50,8 @@ describe FileMover do
expect
(
snippet
.
reload
.
description
)
.
to
eq
(
"test ![banana_sample](/uploads/system/temp/secret55/banana_sample.gif)"
\
" same ![banana_sample](/uploads/system/temp/secret55/banana_sample.gif)"
"test ![banana_sample](/uploads/
-/
system/temp/secret55/banana_sample.gif)"
\
" same ![banana_sample](/uploads/
-/
system/temp/secret55/banana_sample.gif)"
)
end
...
...
spec/uploaders/personal_file_uploader_spec.rb
View file @
180de2d2
...
...
@@ -10,7 +10,7 @@ describe PersonalFileUploader do
dynamic_segment
=
"personal_snippet/
#{
snippet
.
id
}
"
expect
(
described_class
.
absolute_path
(
upload
)).
to
end_with
(
"/system/
#{
dynamic_segment
}
/secret/foo.jpg"
)
expect
(
described_class
.
absolute_path
(
upload
)).
to
end_with
(
"/
-/
system/
#{
dynamic_segment
}
/secret/foo.jpg"
)
end
end
...
...
@@ -19,7 +19,7 @@ describe PersonalFileUploader do
uploader
=
described_class
.
new
(
snippet
,
'secret'
)
allow
(
uploader
).
to
receive
(
:file
).
and_return
(
double
(
extension:
'txt'
,
filename:
'file_name'
))
expected_url
=
"/uploads/system/personal_snippet/
#{
snippet
.
id
}
/secret/file_name"
expected_url
=
"/uploads/
-/
system/personal_snippet/
#{
snippet
.
id
}
/secret/file_name"
expect
(
uploader
.
to_h
).
to
eq
(
alt:
'file_name'
,
...
...
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