Skip to content

Commit

Permalink
fix Members::SetAttributesService role setting specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ulferts committed Oct 9, 2023
1 parent 816f997 commit 5f70474
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
14 changes: 6 additions & 8 deletions spec/services/members/set_attributes_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,12 @@

context 'with a persisted record' do
let(:member) do
build_stubbed(:member, roles: [first_role, second_role]).tap do |m|
allow(m)
.to receive(:touch)
end
build_stubbed(:member, roles: [first_role, second_role])
end

it 'adds the new role' do
expect(subject.result.roles = [second_role, third_role])
it 'adds the new role and marks the other for destruction' do
expect(subject.result.member_roles.map(&:role_id)).to contain_exactly(first_role.id, second_role.id, third_role.id)
expect(subject.result.member_roles.detect { _1.role_id == first_role.id }).to be_marked_for_destruction
end
end

Expand All @@ -126,7 +124,7 @@
end

it 'adds the new role' do
expect(subject.result.roles = [second_role, third_role])
expect(subject.result.member_roles.map(&:role_id)).to contain_exactly(second_role.id, third_role.id)
end

context 'with role_ids not all being present' do
Expand All @@ -137,7 +135,7 @@
end

it 'ignores the empty values' do
expect(subject.result.roles = [second_role, third_role])
expect(subject.result.member_roles.map(&:role_id)).to contain_exactly(second_role.id, third_role.id)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@

context 'with a persisted record' do
let(:member) do
build_stubbed(:work_package_member, roles: [first_role, second_role]) do |m|
allow(m)
.to receive(:touch)
end
build_stubbed(:work_package_member, roles: [first_role, second_role])
end

it 'adds the new role and marks the other for destruction' do
Expand Down

0 comments on commit 5f70474

Please sign in to comment.