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
57ea33bf
Commit
57ea33bf
authored
Mar 31, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend specs for GFM uploads rewriter
parent
b9f57192
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
11 deletions
+32
-11
spec/factories/file_uploader.rb
spec/factories/file_uploader.rb
+3
-2
spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
+29
-9
No files found.
spec/factories/file_uploader.rb
View file @
57ea33bf
FactoryGirl
.
define
do
factory
:file_uploader
,
class:
FileUploader
do
factory
:file_uploader
do
project
secret
nil
transient
do
path
{
File
.
join
(
Rails
.
root
,
'spec/fixtures/rails_sample.jpg'
)
}
fixture
{
'rails_sample.jpg'
}
path
{
File
.
join
(
Rails
.
root
,
'spec/fixtures'
,
fixture
)
}
file
{
Rack
::
Test
::
UploadedFile
.
new
(
path
)
}
end
...
...
spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
View file @
57ea33bf
...
...
@@ -7,15 +7,29 @@ describe Gitlab::Gfm::UploadsRewriter do
let
(
:rewriter
)
{
described_class
.
new
(
text
,
old_project
,
user
)
}
context
'text contains links to uploads'
do
let
(
:uploader
)
{
build
(
:file_uploader
,
project:
old_project
)
}
let
(
:text
)
{
"Text and
#{
uploader
.
to_markdown
}
"
}
let
(
:image_uploader
)
do
build
(
:file_uploader
,
project:
old_project
)
end
let
(
:zip_uploader
)
do
build
(
:file_uploader
,
project:
old_project
,
fixture:
'ci_build_artifacts.zip'
)
end
let
(
:text
)
do
"Text and
#{
image_uploader
.
to_markdown
}
and
#{
zip_uploader
.
to_markdown
}
"
end
describe
'#rewrite'
do
let!
(
:new_text
)
{
rewriter
.
rewrite
(
new_project
)
}
let
(
:new_rewriter
)
{
described_class
.
new
(
new_text
,
new_project
,
user
)
}
let
(
:old_file
)
{
uploader
.
file
}
let
(
:new_file
)
{
new_rewriter
.
files
.
first
}
let
(
:old_files
)
{
[
image_uploader
,
zip_uploader
].
map
(
&
:file
)
}
let
(
:new_files
)
do
described_class
.
new
(
new_text
,
new_project
,
user
).
files
end
let
(
:old_paths
)
{
old_files
.
map
(
&
:path
)
}
let
(
:new_paths
)
{
new_files
.
map
(
&
:path
)
}
it
'rewrites content'
do
expect
(
new_text
).
to_not
eq
text
...
...
@@ -23,13 +37,19 @@ describe Gitlab::Gfm::UploadsRewriter do
end
it
'copies files'
do
expect
(
new_file
.
exists?
).
to
eq
true
expect
(
old_file
.
path
).
to_not
eq
new_file
.
path
expect
(
new_file
.
path
).
to
include
new_project
.
path_with_namespace
expect
(
new_files
).
to
all
(
exist
)
expect
(
old_paths
).
to_not
match_array
new_paths
expect
(
old_paths
).
to
all
(
include
(
old_project
.
path_with_namespace
))
expect
(
new_paths
).
to
all
(
include
(
new_project
.
path_with_namespace
))
end
it
'does not remove old files'
do
expect
(
old_file
).
to
exist
expect
(
old_files
).
to
all
(
exist
)
end
it
'generates a new secret for each file'
do
expect
(
new_paths
).
to_not
include
image_uploader
.
secret
expect
(
new_paths
).
to_not
include
zip_uploader
.
secret
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