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
iv
gitlab-ce
Commits
b9f57192
Commit
b9f57192
authored
Mar 30, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove reduntant `move_to_store` override
parent
99ee8228
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
16 deletions
+10
-16
app/uploaders/file_uploader.rb
app/uploaders/file_uploader.rb
+4
-4
lib/gitlab/gfm/uploads_rewriter.rb
lib/gitlab/gfm/uploads_rewriter.rb
+2
-8
spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
+4
-4
No files found.
app/uploaders/file_uploader.rb
View file @
b9f57192
...
...
@@ -24,10 +24,6 @@ class FileUploader < CarrierWave::Uploader::Base
File
.
join
(
base_dir
,
'tmp'
,
@project
.
path_with_namespace
,
@secret
)
end
def
self
.
generate_secret
SecureRandom
.
hex
end
def
secure_url
File
.
join
(
"/uploads"
,
@secret
,
file
.
filename
)
end
...
...
@@ -50,4 +46,8 @@ class FileUploader < CarrierWave::Uploader::Base
markdown:
markdown
}
end
def
self
.
generate_secret
SecureRandom
.
hex
end
end
lib/gitlab/gfm/uploads_rewriter.rb
View file @
b9f57192
...
...
@@ -17,11 +17,11 @@ module Gitlab
def
rewrite
(
target_project
)
return
@text
unless
needs_rewrite?
new_uploader
=
file_uploader
(
target_project
)
@text
.
gsub
(
@pattern
)
do
|
markdown
|
file
=
find_file
(
@source_project
,
$~
[
:secret
],
$~
[
:file
])
return
markdown
unless
file
.
try
(
:exists?
)
new_uploader
=
FileUploader
.
new
(
target_project
)
new_uploader
.
store!
(
file
)
new_uploader
.
to_markdown
end
...
...
@@ -42,16 +42,10 @@ module Gitlab
private
def
find_file
(
project
,
secret
,
file
)
uploader
=
file_uploader
(
project
,
secret
)
uploader
=
FileUploader
.
new
(
project
,
secret
)
uploader
.
retrieve_from_store!
(
file
)
uploader
.
file
end
def
file_uploader
(
project
,
secret
=
nil
)
uploader
=
FileUploader
.
new
(
project
,
secret
)
uploader
.
define_singleton_method
(
:move_to_store
)
{
false
}
uploader
end
end
end
end
spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
View file @
b9f57192
...
...
@@ -8,13 +8,13 @@ describe Gitlab::Gfm::UploadsRewriter do
context
'text contains links to uploads'
do
let
(
:uploader
)
{
build
(
:file_uploader
,
project:
old_project
)
}
let
(
:markdown
)
{
uploader
.
to_h
[
:markdown
]
}
let
(
:text
)
{
"Text and
#{
markdown
}
"
}
let
(
:text
)
{
"Text and
#{
uploader
.
to_markdown
}
"
}
describe
'#rewrite'
do
let!
(
:new_text
)
{
rewriter
.
rewrite
(
new_project
)
}
let
(
:new_rewriter
)
{
described_class
.
new
(
new_text
,
new_project
,
user
)
}
let
(
:old_file
)
{
rewriter
.
files
.
first
}
let
(
:old_file
)
{
uploader
.
file
}
let
(
:new_file
)
{
new_rewriter
.
files
.
first
}
it
'rewrites content'
do
...
...
@@ -29,7 +29,7 @@ describe Gitlab::Gfm::UploadsRewriter do
end
it
'does not remove old files'
do
expect
(
old_file
.
exists?
).
to
be
true
expect
(
old_file
).
to
exist
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