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
Jérome Perrin
gitlab-ce
Commits
fde90c3e
Commit
fde90c3e
authored
Jun 14, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better coverage for Reader
parent
4020b0f5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
spec/lib/gitlab/import_export/reader_spec.rb
spec/lib/gitlab/import_export/reader_spec.rb
+61
-0
No files found.
spec/lib/gitlab/import_export/reader_spec.rb
View file @
fde90c3e
...
...
@@ -23,4 +23,65 @@ describe Gitlab::ImportExport::Reader, lib: true do
it
'generates hash from project tree config'
do
expect
(
described_class
.
new
(
shared:
shared
).
project_tree
).
to
match
(
project_tree_hash
)
end
context
'individual scenarios'
do
it
'generates the correct hash for a single project relation'
do
setup_yaml
(
project_tree:
[
:issues
])
expect
(
described_class
.
new
(
shared:
shared
).
project_tree
).
to
match
(
include:
[
:issues
])
end
it
'generates the correct hash for a multiple project relation'
do
setup_yaml
(
project_tree:
[
:issues
,
:snippets
])
expect
(
described_class
.
new
(
shared:
shared
).
project_tree
).
to
match
(
include:
[
:issues
,
:snippets
])
end
it
'generates the correct hash for a single sub-relation'
do
setup_yaml
(
project_tree:
[
issues:
[
:notes
]])
expect
(
described_class
.
new
(
shared:
shared
).
project_tree
).
to
match
(
include:
[{
issues:
{
include: :notes
}
}])
end
it
'generates the correct hash for a multiple sub-relation'
do
setup_yaml
(
project_tree:
[
merge_requests:
[
:notes
,
:merge_request_diff
]])
expect
(
described_class
.
new
(
shared:
shared
).
project_tree
).
to
match
(
include:
[{
merge_requests:
{
include:
[
:notes
,
:merge_request_diff
]
}
}])
end
it
'generates the correct hash for a sub-relation with another sub-relation'
do
setup_yaml
(
project_tree:
[
merge_requests:
[
notes: :author
]])
expect
(
described_class
.
new
(
shared:
shared
).
project_tree
).
to
match
(
include:
[{
merge_requests:
{
include:
{
notes:
{
include: :author
}
}
}
}])
end
it
'generates the correct hash for a relation with included attributes'
do
setup_yaml
(
project_tree:
[
:issues
],
included_attributes:
{
issues:
[
:name
,
:description
]})
expect
(
described_class
.
new
(
shared:
shared
).
project_tree
).
to
match
(
include:
[{
issues:
{
only:
[
:name
,
:description
]
}
}])
end
it
'generates the correct hash for a relation with excluded attributes'
do
setup_yaml
(
project_tree:
[
:issues
],
excluded_attributes:
{
issues:
[
:name
]})
expect
(
described_class
.
new
(
shared:
shared
).
project_tree
).
to
match
(
include:
[{
issues:
{
except:
[
:name
]
}
}])
end
it
'generates the correct hash for a relation with both excluded and included attributes'
do
setup_yaml
(
project_tree:
[
:issues
],
excluded_attributes:
{
issues:
[
:name
]},
included_attributes:
{
issues:
[
:description
]})
expect
(
described_class
.
new
(
shared:
shared
).
project_tree
).
to
match
(
include:
[{
issues:
{
except:
[
:name
],
only:
[
:description
]}
}])
end
it
'generates the correct hash for a relation with custom methods'
do
setup_yaml
(
project_tree:
[
:issues
],
methods:
{
issues:
[
:name
]})
expect
(
described_class
.
new
(
shared:
shared
).
project_tree
).
to
match
(
include:
[{
issues:
{
methods:
[
:name
]
}
}])
end
def
setup_yaml
(
hash
)
allow
(
YAML
).
to
receive
(
:load_file
).
with
(
test_config
).
and_return
(
hash
)
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