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
18d3b38e
Commit
18d3b38e
authored
Mar 11, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
project members: fixed a few issues. Specs now passing
parent
7b855b75
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
20 deletions
+27
-20
members_mapper.rb
app/services/projects/import_export/members_mapper.rb
+2
-1
members_mapper_spec.rb
spec/services/projects/import_export/members_mapper_spec.rb
+25
-19
No files found.
app/services/projects/import_export/members_mapper.rb
View file @
18d3b38e
...
...
@@ -30,13 +30,14 @@ module Projects
def
assign_member
(
existing_user
,
member
)
member
[
'user'
]
=
existing_user
project_member
=
ProjectMember
.
new
(
member_hash
(
member
))
@project_member_map
[
member
[
'id'
]
]
=
project_member
if
project_member
.
save
@project_member_map
[
existing_user
.
id
]
=
project_member
if
project_member
.
save
end
def
member_hash
(
member
)
member
.
except
(
'id'
).
merge
(
source_id:
@project_id
)
end
#TODO: If default, then we need to leave a comment 'Comment by <original username>' on comments
def
default_project_member
@default_project_member
||=
begin
...
...
spec/services/projects/import_export/members_mapper_spec.rb
View file @
18d3b38e
...
...
@@ -6,21 +6,27 @@ describe Projects::ImportExport::MembersMapper, services: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
name:
'searchable_project'
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:exported_members
)
{
[
{
"id"
=>
2
,
"access_level"
=>
40
,
"source_id"
=>
14
,
"source_type"
=>
"Project"
,
"user_id"
=>
19
,
"notification_level"
=>
3
,
"created_at"
=>
"2016-03-11T10:21:44.822Z"
,
"updated_at"
=>
"2016-03-11T10:21:44.822Z"
,
"created_by_id"
=>
nil
,
"invite_email"
=>
nil
,
"invite_token"
=>
nil
,
"invite_accepted_at"
=>
nil
,
"user"
=>
{
"email"
=>
user2
.
email
,
"username"
=>
user2
.
username
}
}]
}
let
(
:exported_members
)
do
[{
"id"
=>
2
,
"access_level"
=>
40
,
"source_id"
=>
14
,
"source_type"
=>
"Project"
,
"user_id"
=>
19
,
"notification_level"
=>
3
,
"created_at"
=>
"2016-03-11T10:21:44.822Z"
,
"updated_at"
=>
"2016-03-11T10:21:44.822Z"
,
"created_by_id"
=>
nil
,
"invite_email"
=>
nil
,
"invite_token"
=>
nil
,
"invite_accepted_at"
=>
nil
,
"user"
=>
{
"email"
=>
user2
.
email
,
"username"
=>
user2
.
username
}
}]
end
let
(
:members_mapper
)
do
Projects
::
ImportExport
::
MembersMapper
.
new
(
...
...
@@ -28,15 +34,15 @@ describe Projects::ImportExport::MembersMapper, services: true do
end
it
'maps a project member'
do
expect
(
project_member_
map
_id
(
user2
.
id
)).
to
eq
(
user2
.
id
)
expect
(
project_member_
user
_id
(
user2
.
id
)).
to
eq
(
user2
.
id
)
end
it
'defaults to importer project member if it does not exist'
do
expect
(
project_member_
map
_id
(
-
1
)).
to
eq
(
user
.
id
)
expect
(
project_member_
user
_id
(
-
1
)).
to
eq
(
user
.
id
)
end
end
def
project_member_
map
_id
(
id
)
members_mapper
.
map
[
id
]
[
'id'
]
def
project_member_
user
_id
(
id
)
members_mapper
.
map
[
id
]
.
user
.
id
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