Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-09 15:08:22 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-09 15:08:22 +0300
commitd022b7432efd720f0cf5f8d2a2cdaac7619bab57 (patch)
tree5b6e0a107019e8160957624380919913b084a68d /spec/services/todo_service_spec.rb
parent73add99b1f4ce720f1fe00e828fb6991f27af6fb (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/todo_service_spec.rb')
-rw-r--r--spec/services/todo_service_spec.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb
index 94d4b61933d..86a428bca92 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") }
@@ -605,6 +639,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") }