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
03970a00
Commit
03970a00
authored
Apr 01, 2020
by
Nikola Milojevic
Committed by
Peter Leitzen
Apr 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs for streamin serializer
- remove uneccesery allow - reodred lets - fix " and ' to be
parent
1cef19ba
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb
...ib/gitlab/import_export/json/streaming_serializer_spec.rb
+98
-0
No files found.
spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb
0 → 100644
View file @
03970a00
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
ImportExport
::
JSON
::
StreamingSerializer
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:release
)
{
create
(
:release
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:exportable
)
do
create
(
:project
,
:public
,
:repository
,
:issues_disabled
,
:wiki_enabled
,
:builds_private
,
description:
'description'
,
releases:
[
release
],
group:
group
,
approvals_before_merge:
1
)
end
let_it_be
(
:issue
)
do
create
(
:issue
,
assignees:
[
user
],
project:
exportable
)
end
let
(
:exportable_path
)
{
'project'
}
let
(
:json_writer
)
{
instance_double
(
'Gitlab::ImportExport::JSON::LegacyWriter'
)
}
let
(
:hash
)
{
{
name:
exportable
.
name
,
description:
exportable
.
description
}.
stringify_keys
}
let
(
:include
)
{
[]
}
let
(
:relations_schema
)
do
{
only:
[
:name
,
:description
],
include:
include
,
preload:
{
issues:
nil
}
}
end
subject
do
described_class
.
new
(
exportable
,
relations_schema
,
json_writer
,
exportable_path:
exportable_path
)
end
describe
'#execute'
do
before
do
allow
(
json_writer
).
to
receive
(
:write_attributes
).
with
(
exportable_path
,
hash
)
end
it
'calls json_writer.write_attributes with proper params'
do
subject
.
execute
end
context
'with many relations'
do
let
(
:include
)
do
[{
issues:
{
include:
[]
}
}]
end
it
'calls json_writer.write_relation_array with proper params'
do
expect
(
json_writer
).
to
receive
(
:write_relation_array
).
with
(
exportable_path
,
:issues
,
array_including
(
issue
.
to_json
))
subject
.
execute
end
end
context
'with single relation'
do
let
(
:group_options
)
do
{
include:
[],
only:
[
:name
,
:path
,
:description
]
}
end
let
(
:include
)
do
[{
group:
group_options
}]
end
it
'calls json_writer.write_relation with proper params'
do
expect
(
json_writer
).
to
receive
(
:write_relation
).
with
(
exportable_path
,
:group
,
group
.
to_json
(
group_options
))
subject
.
execute
end
end
context
'with array relation'
do
let
(
:project_member
)
{
create
(
:project_member
,
user:
user
)
}
let
(
:include
)
do
[{
project_members:
{
include:
[]
}
}]
end
before
do
allow
(
exportable
).
to
receive
(
:project_members
).
and_return
([
project_member
])
end
it
'calls json_writer.write_relation_array with proper params'
do
expect
(
json_writer
).
to
receive
(
:write_relation_array
).
with
(
exportable_path
,
:project_members
,
array_including
(
project_member
.
to_json
))
subject
.
execute
end
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