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
c06eb779
Commit
c06eb779
authored
Oct 30, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the Hashed Storage compatible layer to store Attachments
parent
b1907694
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
14 deletions
+40
-14
app/uploaders/file_uploader.rb
app/uploaders/file_uploader.rb
+1
-1
spec/uploaders/file_uploader_spec.rb
spec/uploaders/file_uploader_spec.rb
+39
-13
No files found.
app/uploaders/file_uploader.rb
View file @
c06eb779
...
...
@@ -30,7 +30,7 @@ class FileUploader < GitlabUploader
#
# Returns a String without a trailing slash
def
self
.
dynamic_path_segment
(
model
)
File
.
join
(
CarrierWave
.
root
,
base_dir
,
model
.
full
_path
)
File
.
join
(
CarrierWave
.
root
,
base_dir
,
model
.
disk
_path
)
end
attr_accessor
:model
...
...
spec/uploaders/file_uploader_spec.rb
View file @
c06eb779
...
...
@@ -3,25 +3,51 @@ require 'spec_helper'
describe
FileUploader
do
let
(
:uploader
)
{
described_class
.
new
(
build_stubbed
(
:project
))
}
describe
'.absolute_path'
do
it
'returns the correct absolute path by building it dynamically'
do
project
=
build_stubbed
(
:project
)
upload
=
double
(
model:
project
,
path:
'secret/foo.jpg'
)
context
'legacy storage'
do
let
(
:project
)
{
build_stubbed
(
:project
)
}
dynamic_segment
=
project
.
path_with_namespace
describe
'.absolute_path'
do
it
'returns the correct absolute path by building it dynamically'
do
upload
=
double
(
model:
project
,
path:
'secret/foo.jpg'
)
expect
(
described_class
.
absolute_path
(
upload
))
.
to
end_with
(
"
#{
dynamic_segment
}
/secret/foo.jpg"
)
dynamic_segment
=
project
.
full_path
expect
(
described_class
.
absolute_path
(
upload
))
.
to
end_with
(
"
#{
dynamic_segment
}
/secret/foo.jpg"
)
end
end
describe
"#store_dir"
do
it
"stores in the namespace path"
do
uploader
=
described_class
.
new
(
project
)
expect
(
uploader
.
store_dir
).
to
include
(
project
.
full_path
)
expect
(
uploader
.
store_dir
).
not_to
include
(
"system"
)
end
end
end
describe
"#store_dir"
do
it
"stores in the namespace path"
do
project
=
build_stubbed
(
:project
)
uploader
=
described_class
.
new
(
project
)
context
'hashed storage'
do
let
(
:project
)
{
build_stubbed
(
:project
,
:hashed
)
}
describe
'.absolute_path'
do
it
'returns the correct absolute path by building it dynamically'
do
upload
=
double
(
model:
project
,
path:
'secret/foo.jpg'
)
dynamic_segment
=
project
.
disk_path
expect
(
described_class
.
absolute_path
(
upload
))
.
to
end_with
(
"
#{
dynamic_segment
}
/secret/foo.jpg"
)
end
end
describe
"#store_dir"
do
it
"stores in the namespace path"
do
uploader
=
described_class
.
new
(
project
)
expect
(
uploader
.
store_dir
).
to
include
(
project
.
path_with_namespace
)
expect
(
uploader
.
store_dir
).
not_to
include
(
"system"
)
expect
(
uploader
.
store_dir
).
to
include
(
project
.
disk_path
)
expect
(
uploader
.
store_dir
).
not_to
include
(
"system"
)
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