|
|
|
@ -46,10 +46,14 @@ describe ::API::V3::WorkPackages::WorkPackageSqlRepresenter, 'rendering' do |
|
|
|
|
let(:rendered_work_package) do |
|
|
|
|
create(:work_package, |
|
|
|
|
project: project, |
|
|
|
|
assigned_to: assignee) |
|
|
|
|
assigned_to: assignee, |
|
|
|
|
author: author, |
|
|
|
|
responsible: responsible) |
|
|
|
|
end |
|
|
|
|
let(:project) { create(:project) } |
|
|
|
|
let(:assignee) { create(:user) } |
|
|
|
|
let(:assignee) { nil } |
|
|
|
|
let(:author) { create(:user) } |
|
|
|
|
let(:responsible) { nil } |
|
|
|
|
|
|
|
|
|
let(:select) { { '*' => {} } } |
|
|
|
|
|
|
|
|
@ -73,8 +77,14 @@ describe ::API::V3::WorkPackages::WorkPackageSqlRepresenter, 'rendering' do |
|
|
|
|
title: project.name |
|
|
|
|
}, |
|
|
|
|
assignee: { |
|
|
|
|
href: api_v3_paths.user(assignee.id), |
|
|
|
|
title: assignee.name |
|
|
|
|
href: nil |
|
|
|
|
}, |
|
|
|
|
responsible: { |
|
|
|
|
href: nil |
|
|
|
|
}, |
|
|
|
|
author: { |
|
|
|
|
href: api_v3_paths.user(author.id), |
|
|
|
|
title: author.name |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -86,16 +96,18 @@ describe ::API::V3::WorkPackages::WorkPackageSqlRepresenter, 'rendering' do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'assignee link' do |
|
|
|
|
let(:select) { { 'assignee' => {} } } |
|
|
|
|
shared_examples_for 'principal link' do |link_name, only_user: false| |
|
|
|
|
let(:select) { { link_name => {} } } |
|
|
|
|
|
|
|
|
|
context 'with a user' do |
|
|
|
|
let(:principal_object) { create(:user) } |
|
|
|
|
|
|
|
|
|
let(:expected) do |
|
|
|
|
{ |
|
|
|
|
_links: { |
|
|
|
|
assignee: { |
|
|
|
|
href: api_v3_paths.user(assignee.id), |
|
|
|
|
title: assignee.name |
|
|
|
|
link_name => { |
|
|
|
|
href: api_v3_paths.user(principal_object.id), |
|
|
|
|
title: principal_object.name |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -107,44 +119,64 @@ describe ::API::V3::WorkPackages::WorkPackageSqlRepresenter, 'rendering' do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with a group' do |
|
|
|
|
let(:assignee) { create(:group) } |
|
|
|
|
|
|
|
|
|
let(:expected) do |
|
|
|
|
{ |
|
|
|
|
_links: { |
|
|
|
|
assignee: { |
|
|
|
|
href: api_v3_paths.group(assignee.id), |
|
|
|
|
title: assignee.name |
|
|
|
|
unless only_user |
|
|
|
|
context 'with a group' do |
|
|
|
|
let(:principal_object) { create(:group) } |
|
|
|
|
|
|
|
|
|
let(:expected) do |
|
|
|
|
{ |
|
|
|
|
_links: { |
|
|
|
|
link_name => { |
|
|
|
|
href: api_v3_paths.group(principal_object.id), |
|
|
|
|
title: principal_object.name |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'renders as expected' do |
|
|
|
|
expect(json) |
|
|
|
|
.to be_json_eql(expected.to_json) |
|
|
|
|
it 'renders as expected' do |
|
|
|
|
expect(json) |
|
|
|
|
.to be_json_eql(expected.to_json) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with a placeholder user' do |
|
|
|
|
let(:assignee) { create(:placeholder_user) } |
|
|
|
|
context 'with a placeholder user' do |
|
|
|
|
let(:principal_object) { create(:placeholder_user) } |
|
|
|
|
|
|
|
|
|
let(:expected) do |
|
|
|
|
{ |
|
|
|
|
_links: { |
|
|
|
|
assignee: { |
|
|
|
|
href: api_v3_paths.placeholder_user(assignee.id), |
|
|
|
|
title: assignee.name |
|
|
|
|
let(:expected) do |
|
|
|
|
{ |
|
|
|
|
_links: { |
|
|
|
|
link_name => { |
|
|
|
|
href: api_v3_paths.placeholder_user(principal_object.id), |
|
|
|
|
title: principal_object.name |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'renders as expected' do |
|
|
|
|
expect(json) |
|
|
|
|
.to be_json_eql(expected.to_json) |
|
|
|
|
it 'renders as expected' do |
|
|
|
|
expect(json) |
|
|
|
|
.to be_json_eql(expected.to_json) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'assignee link' do |
|
|
|
|
it_behaves_like 'principal link', 'assignee' do |
|
|
|
|
let(:assignee) { principal_object } |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'responsible link' do |
|
|
|
|
it_behaves_like 'principal link', 'responsible' do |
|
|
|
|
let(:responsible) { principal_object } |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'author link' do |
|
|
|
|
it_behaves_like 'principal link', 'author', only_user: true do |
|
|
|
|
let(:author) { principal_object } |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|