BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
779ed1cc
Unverified
Commit
779ed1cc
authored
Jan 18, 2018
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix spec/migrations/update_upload_paths_to_system_spec.rb to use the :migration metadata
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
2af0b083
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
26 deletions
+32
-26
update_upload_paths_to_system_spec.rb
spec/migrations/update_upload_paths_to_system_spec.rb
+32
-26
No files found.
spec/migrations/update_upload_paths_to_system_spec.rb
View file @
779ed1cc
require
"spec_helper"
require
'spec_helper'
require
Rails
.
root
.
join
(
"db"
,
"post_migrate"
,
"20170317162059_update_upload_paths_to_system.rb"
)
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20170317162059_update_upload_paths_to_system.rb'
)
describe
UpdateUploadPathsToSystem
do
describe
UpdateUploadPathsToSystem
,
:migration
do
let
(
:migration
)
{
described_class
.
new
}
let
(
:migration
)
{
described_class
.
new
}
let
(
:uploads_table
)
{
table
(
:uploads
)
}
let
(
:base_upload_attributes
)
{
{
size:
42
,
uploader:
'John Doe'
}
}
before
do
before
do
allow
(
migration
).
to
receive
(
:say
)
allow
(
migration
).
to
receive
(
:say
)
end
end
describe
"#uploads_to_switch_to_new_path"
do
describe
'#uploads_to_switch_to_new_path'
do
it
"contains only uploads with the old path for the correct models"
do
it
'contains only uploads with the old path for the correct models'
do
_upload_for_other_type
=
create
(
:upload
,
model:
create
(
:ci_pipeline
),
path:
"uploads/ci_pipeline/avatar.jpg"
)
_upload_for_other_type
=
create
_upload
(
'Pipeline'
,
'uploads/ci_pipeline/avatar.jpg'
)
_upload_with_system_path
=
create
(
:upload
,
model:
create
(
:project
),
path:
"uploads/-/system/project/avatar.jpg"
)
_upload_with_system_path
=
create
_upload
(
'Project'
,
'uploads/-/system/project/avatar.jpg'
)
_upload_with_other_path
=
create
(
:upload
,
model:
create
(
:project
),
path:
"thelongsecretforafileupload/avatar.jpg"
)
_upload_with_other_path
=
create
_upload
(
'Project'
,
'thelongsecretforafileupload/avatar.jpg'
)
old_upload
=
create
(
:upload
,
model:
create
(
:project
),
path:
"uploads/project/avatar.jpg"
)
old_upload
=
create
_upload
(
'Project'
,
'uploads/project/avatar.jpg'
)
group_upload
=
create
(
:upload
,
model:
create
(
:group
),
path:
"uploads/group/avatar.jpg"
)
group_upload
=
create
_upload
(
'Namespace'
,
'uploads/group/avatar.jpg'
)
expect
(
Upload
.
where
(
migration
.
uploads_to_switch_to_new_path
)).
to
contain_exactly
(
old_upload
,
group_upload
)
expect
(
uploads_table
.
where
(
migration
.
uploads_to_switch_to_new_path
)).
to
contain_exactly
(
old_upload
,
group_upload
)
end
end
end
end
describe
"#uploads_to_switch_to_old_path"
do
describe
'#uploads_to_switch_to_old_path'
do
it
"contains only uploads with the new path for the correct models"
do
it
'contains only uploads with the new path for the correct models'
do
_upload_for_other_type
=
create
(
:upload
,
model:
create
(
:ci_pipeline
),
path:
"uploads/ci_pipeline/avatar.jpg"
)
_upload_for_other_type
=
create
_upload
(
'Pipeline'
,
'uploads/ci_pipeline/avatar.jpg'
)
upload_with_system_path
=
create
(
:upload
,
model:
create
(
:project
),
path:
"uploads/-/system/project/avatar.jpg"
)
upload_with_system_path
=
create
_upload
(
'Project'
,
'uploads/-/system/project/avatar.jpg'
)
_upload_with_other_path
=
create
(
:upload
,
model:
create
(
:project
),
path:
"thelongsecretforafileupload/avatar.jpg"
)
_upload_with_other_path
=
create
_upload
(
'Project'
,
'thelongsecretforafileupload/avatar.jpg'
)
_old_upload
=
create
(
:upload
,
model:
create
(
:project
),
path:
"uploads/project/avatar.jpg"
)
_old_upload
=
create
_upload
(
'Project'
,
'uploads/project/avatar.jpg'
)
expect
(
Upload
.
where
(
migration
.
uploads_to_switch_to_old_path
)).
to
contain_exactly
(
upload_with_system_path
)
expect
(
uploads_table
.
where
(
migration
.
uploads_to_switch_to_old_path
)).
to
contain_exactly
(
upload_with_system_path
)
end
end
end
end
describe
"#up"
,
:truncate
do
describe
'#up'
do
it
"updates old upload records to the new path"
do
it
'updates old upload records to the new path'
do
old_upload
=
create
(
:upload
,
model:
create
(
:project
),
path:
"uploads/project/avatar.jpg"
)
old_upload
=
create
_upload
(
'Project'
,
'uploads/project/avatar.jpg'
)
migration
.
up
migration
.
up
expect
(
old_upload
.
reload
.
path
).
to
eq
(
"uploads/-/system/project/avatar.jpg"
)
expect
(
old_upload
.
reload
.
path
).
to
eq
(
'uploads/-/system/project/avatar.jpg'
)
end
end
end
end
describe
"#down"
,
:truncate
do
describe
'#down'
do
it
"updates the new system patsh to the old paths"
do
it
'updates the new system patsh to the old paths'
do
new_upload
=
create
(
:upload
,
model:
create
(
:project
),
path:
"uploads/-/system/project/avatar.jpg"
)
new_upload
=
create
_upload
(
'Project'
,
'uploads/-/system/project/avatar.jpg'
)
migration
.
down
migration
.
down
expect
(
new_upload
.
reload
.
path
).
to
eq
(
"uploads/project/avatar.jpg"
)
expect
(
new_upload
.
reload
.
path
).
to
eq
(
'uploads/project/avatar.jpg'
)
end
end
end
end
def
create_upload
(
type
,
path
)
uploads_table
.
create
(
base_upload_attributes
.
merge
(
model_type:
type
,
path:
path
))
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