BigW Consortium Gitlab

Commit 18d3b38e by James Lopez

project members: fixed a few issues. Specs now passing

parent 7b855b75
......@@ -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
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment