diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/services/todo_service_spec.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/services/todo_service_spec.rb')
-rw-r--r-- | spec/services/todo_service_spec.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb index 94d4b61933d..60903f8f367 100644 --- a/spec/services/todo_service_spec.rb +++ b/spec/services/todo_service_spec.rb @@ -65,6 +65,40 @@ RSpec.describe TodoService do end end + shared_examples 'reassigned reviewable target' do + context 'with no existing reviewers' do + let(:assigned_reviewers) { [] } + + it 'creates a pending todo for new reviewer' do + target.reviewers = [john_doe] + service.send(described_method, target, author) + + should_create_todo(user: john_doe, target: target, action: Todo::REVIEW_REQUESTED) + end + end + + context 'with an existing reviewer' do + let(:assigned_reviewers) { [john_doe] } + + it 'does not create a todo if unassigned' do + target.reviewers = [] + + should_not_create_any_todo { service.send(described_method, target, author) } + end + + it 'creates a todo if new reviewer is the current user' do + target.reviewers = [john_doe] + service.send(described_method, target, john_doe) + + should_create_todo(user: john_doe, target: target, author: john_doe, action: Todo::REVIEW_REQUESTED) + end + + it 'does not create a todo if already assigned' do + should_not_create_any_todo { service.send(described_method, target, author, [john_doe]) } + end + end + end + describe 'Issues' do let(:issue) { create(:issue, project: project, assignees: [john_doe], author: author, description: "- [ ] Task 1\n- [ ] Task 2 #{mentions}") } let(:addressed_issue) { create(:issue, project: project, assignees: [john_doe], author: author, description: "#{directly_addressed}\n- [ ] Task 1\n- [ ] Task 2") } @@ -160,6 +194,19 @@ RSpec.describe TodoService do should_create_todo(user: john_doe, target: issue) end end + + context 'issue is an incident' do + let(:issue) { create(:incident, project: project, assignees: [john_doe], author: author) } + + subject do + service.new_issue(issue, author) + should_create_todo(user: john_doe, target: issue, action: Todo::ASSIGNED) + end + + it_behaves_like 'an incident management tracked event', :incident_management_incident_todo do + let(:current_user) { john_doe} + end + end end describe '#update_issue' do @@ -605,6 +652,17 @@ RSpec.describe TodoService do end end + describe '#reassigned_reviewable' do + let(:described_method) { :reassigned_reviewable } + + context 'reviewable is a merge request' do + it_behaves_like 'reassigned reviewable target' do + let(:assigned_reviewers) { [] } + let(:target) { create(:merge_request, source_project: project, author: author, reviewers: assigned_reviewers) } + end + end + end + describe 'Merge Requests' do let(:mr_assigned) { create(:merge_request, source_project: project, author: author, assignees: [john_doe], description: "- [ ] Task 1\n- [ ] Task 2 #{mentions}") } let(:addressed_mr_assigned) { create(:merge_request, source_project: project, author: author, assignees: [john_doe], description: "#{directly_addressed}\n- [ ] Task 1\n- [ ] Task 2") } |