From 5f70474ddfca1677fa4e0e98790ce5d27c54207f Mon Sep 17 00:00:00 2001 From: ulferts Date: Mon, 9 Oct 2023 15:54:35 +0200 Subject: [PATCH] fix Members::SetAttributesService role setting specs --- .../members/set_attributes_service_spec.rb | 14 ++++++-------- .../set_attributes_service_spec.rb | 5 +---- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/spec/services/members/set_attributes_service_spec.rb b/spec/services/members/set_attributes_service_spec.rb index 494ad657ae67..ab1b9a190ef0 100644 --- a/spec/services/members/set_attributes_service_spec.rb +++ b/spec/services/members/set_attributes_service_spec.rb @@ -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 @@ -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 @@ -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 diff --git a/spec/services/work_package_members/set_attributes_service_spec.rb b/spec/services/work_package_members/set_attributes_service_spec.rb index 5f5919a4e1fe..574235dfc38e 100644 --- a/spec/services/work_package_members/set_attributes_service_spec.rb +++ b/spec/services/work_package_members/set_attributes_service_spec.rb @@ -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