diff options
Diffstat (limited to 'spec/services/issuable')
-rw-r--r-- | spec/services/issuable/destroy_service_spec.rb | 21 | ||||
-rw-r--r-- | spec/services/issuable/process_assignees_spec.rb | 32 |
2 files changed, 24 insertions, 29 deletions
diff --git a/spec/services/issuable/destroy_service_spec.rb b/spec/services/issuable/destroy_service_spec.rb index 8d62932f986..fa4902e5237 100644 --- a/spec/services/issuable/destroy_service_spec.rb +++ b/spec/services/issuable/destroy_service_spec.rb @@ -4,7 +4,8 @@ require 'spec_helper' RSpec.describe Issuable::DestroyService do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:group) { create(:group, :public) } + let(:project) { create(:project, :public, group: group) } subject(:service) { described_class.new(project, user) } @@ -22,17 +23,14 @@ RSpec.describe Issuable::DestroyService do service.execute(issue) end - it 'updates the todo caches for users with todos on the issue' do - create(:todo, target: issue, user: user, author: user, project: project) - - expect { service.execute(issue) } - .to change { user.todos_pending_count }.from(1).to(0) - end - it 'invalidates the issues count cache for the assignees' do expect_any_instance_of(User).to receive(:invalidate_cache_counts).once service.execute(issue) end + + it_behaves_like 'service deleting todos' do + let(:issuable) { issue } + end end context 'when issuable is a merge request' do @@ -53,11 +51,8 @@ RSpec.describe Issuable::DestroyService do service.execute(merge_request) end - it 'updates the todo caches for users with todos on the merge request' do - create(:todo, target: merge_request, user: user, author: user, project: project) - - expect { service.execute(merge_request) } - .to change { user.todos_pending_count }.from(1).to(0) + it_behaves_like 'service deleting todos' do + let(:issuable) { merge_request } end end end diff --git a/spec/services/issuable/process_assignees_spec.rb b/spec/services/issuable/process_assignees_spec.rb index 876c84957cc..45d57a1772a 100644 --- a/spec/services/issuable/process_assignees_spec.rb +++ b/spec/services/issuable/process_assignees_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' RSpec.describe Issuable::ProcessAssignees do describe '#execute' do - it 'returns assignee_ids when assignee_ids are specified' do + it 'returns assignee_ids when add_assignee_ids and remove_assignee_ids are not specified' do process = Issuable::ProcessAssignees.new(assignee_ids: %w(5 7 9), - add_assignee_ids: %w(2 4 6), - remove_assignee_ids: %w(4 7 11), + add_assignee_ids: nil, + remove_assignee_ids: nil, existing_assignee_ids: %w(1 3 9), extra_assignee_ids: %w(2 5 12)) result = process.execute @@ -15,19 +15,19 @@ RSpec.describe Issuable::ProcessAssignees do expect(result.sort).to eq(%w(5 7 9).sort) end - it 'combines other ids when assignee_ids is empty' do - process = Issuable::ProcessAssignees.new(assignee_ids: [], - add_assignee_ids: %w(2 4 6), - remove_assignee_ids: %w(4 7 11), + it 'combines other ids when assignee_ids is nil' do + process = Issuable::ProcessAssignees.new(assignee_ids: nil, + add_assignee_ids: nil, + remove_assignee_ids: nil, existing_assignee_ids: %w(1 3 11), extra_assignee_ids: %w(2 5 12)) result = process.execute - expect(result.sort).to eq(%w(1 2 3 5 6 12).sort) + expect(result.sort).to eq(%w(1 2 3 5 11 12).sort) end - it 'combines other ids when assignee_ids is nil' do - process = Issuable::ProcessAssignees.new(assignee_ids: nil, + it 'combines other ids when both add_assignee_ids and remove_assignee_ids are not empty' do + process = Issuable::ProcessAssignees.new(assignee_ids: %w(5 7 9), add_assignee_ids: %w(2 4 6), remove_assignee_ids: %w(4 7 11), existing_assignee_ids: %w(1 3 11), @@ -37,8 +37,8 @@ RSpec.describe Issuable::ProcessAssignees do expect(result.sort).to eq(%w(1 2 3 5 6 12).sort) end - it 'combines other ids when assignee_ids and add_assignee_ids are nil' do - process = Issuable::ProcessAssignees.new(assignee_ids: nil, + it 'combines other ids when remove_assignee_ids is not empty' do + process = Issuable::ProcessAssignees.new(assignee_ids: %w(5 7 9), add_assignee_ids: nil, remove_assignee_ids: %w(4 7 11), existing_assignee_ids: %w(1 3 11), @@ -48,8 +48,8 @@ RSpec.describe Issuable::ProcessAssignees do expect(result.sort).to eq(%w(1 2 3 5 12).sort) end - it 'combines other ids when assignee_ids and remove_assignee_ids are nil' do - process = Issuable::ProcessAssignees.new(assignee_ids: nil, + it 'combines other ids when add_assignee_ids is not empty' do + process = Issuable::ProcessAssignees.new(assignee_ids: %w(5 7 9), add_assignee_ids: %w(2 4 6), remove_assignee_ids: nil, existing_assignee_ids: %w(1 3 11), @@ -59,8 +59,8 @@ RSpec.describe Issuable::ProcessAssignees do expect(result.sort).to eq(%w(1 2 4 3 5 6 11 12).sort) end - it 'combines ids when only add_assignee_ids and remove_assignee_ids are passed' do - process = Issuable::ProcessAssignees.new(assignee_ids: nil, + it 'combines ids when existing_assignee_ids and extra_assignee_ids are omitted' do + process = Issuable::ProcessAssignees.new(assignee_ids: %w(5 7 9), add_assignee_ids: %w(2 4 6), remove_assignee_ids: %w(4 7 11)) result = process.execute |