2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe SystemNoteService do
|
2017-09-10 17:25:29 +05:30
|
|
|
include Gitlab::Routing
|
2018-03-17 18:26:18 +05:30
|
|
|
include RepoHelpers
|
2018-11-08 19:23:39 +05:30
|
|
|
include AssetsHelpers
|
2020-05-24 23:13:21 +05:30
|
|
|
include DesignManagementTestHelpers
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:project) { create(:project, :repository, group: group) }
|
|
|
|
let_it_be(:author) { create(:user) }
|
2021-09-30 23:02:18 +05:30
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
let(:noteable) { create(:issue, project: project) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:issue) { noteable }
|
2015-09-11 14:41:01 +05:30
|
|
|
|
|
|
|
describe '.add_commits' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:new_commits) { double }
|
|
|
|
let(:old_commits) { double }
|
|
|
|
let(:oldrev) { double }
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls CommitService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::CommitService) do |service|
|
|
|
|
expect(service).to receive(:add_commits).with(new_commits, old_commits, oldrev)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.add_commits(noteable, project, author, new_commits, old_commits, oldrev)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
describe '.tag_commit' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:tag_name) { double }
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls CommitService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::CommitService) do |service|
|
|
|
|
expect(service).to receive(:tag_commit).with(tag_name)
|
|
|
|
end
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.tag_commit(noteable, project, author, tag_name)
|
2018-11-20 20:47:30 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
describe '.change_assignee' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:assignee) { double }
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:change_assignee).with(assignee)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.change_assignee(noteable, project, author, assignee)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
describe '.change_issuable_assignees' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:assignees) { [double, double] }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:change_issuable_assignees).with(assignees)
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
described_class.change_issuable_assignees(noteable, project, author, assignees)
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
describe '.change_issuable_reviewers' do
|
|
|
|
let(:reviewers) { [double, double] }
|
|
|
|
|
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:change_issuable_reviewers).with(reviewers)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.change_issuable_reviewers(noteable, project, author, reviewers)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
describe '.close_after_error_tracking_resolve' do
|
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:close_after_error_tracking_resolve)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.close_after_error_tracking_resolve(noteable, project, author)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
describe '.relate_issue' do
|
|
|
|
let(:noteable_ref) { double }
|
|
|
|
let(:noteable) { double }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(noteable).to receive(:project).and_return(double)
|
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(service).to receive(:relate_issue).with(noteable_ref)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
described_class.relate_issue(noteable, noteable_ref, double)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.unrelate_issue' do
|
|
|
|
let(:noteable_ref) { double }
|
|
|
|
let(:noteable) { double }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(noteable).to receive(:project).and_return(double)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:unrelate_issue).with(noteable_ref)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.unrelate_issue(noteable, noteable_ref, double)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
describe '.change_due_date' do
|
2020-03-13 15:44:24 +05:30
|
|
|
let(:due_date) { double }
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it 'calls TimeTrackingService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::TimeTrackingService) do |service|
|
|
|
|
expect(service).to receive(:change_due_date).with(due_date)
|
2018-11-20 20:47:30 +05:30
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
described_class.change_due_date(noteable, project, author, due_date)
|
2018-11-20 20:47:30 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
describe '.change_status' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:status) { double }
|
|
|
|
let(:source) { double }
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:change_status).with(status, source)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.change_status(noteable, project, author, status, source)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
describe '.request_attention' do
|
|
|
|
let(:user) { double }
|
|
|
|
|
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:request_attention).with(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.request_attention(noteable, project, author, user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.remove_attention_request' do
|
|
|
|
let(:user) { double }
|
|
|
|
|
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:remove_attention_request).with(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.remove_attention_request(noteable, project, author, user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
describe '.merge_when_pipeline_succeeds' do
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
sha = double
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
|
|
|
expect(service).to receive(:merge_when_pipeline_succeeds).with(sha)
|
|
|
|
end
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
described_class.merge_when_pipeline_succeeds(noteable, project, author, sha)
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
describe '.cancel_merge_when_pipeline_succeeds' do
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
|
|
|
expect(service).to receive(:cancel_merge_when_pipeline_succeeds)
|
|
|
|
end
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
described_class.cancel_merge_when_pipeline_succeeds(noteable, project, author)
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
describe '.abort_merge_when_pipeline_succeeds' do
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
reason = double
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
|
|
|
expect(service).to receive(:abort_merge_when_pipeline_succeeds).with(reason)
|
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
described_class.abort_merge_when_pipeline_succeeds(noteable, project, author, reason)
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
describe '.change_title' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:title) { double }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:change_title).with(title)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.change_title(noteable, project, author, title)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.change_description' do
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:change_description)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.change_description(noteable, project, author)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
describe '.change_issue_confidentiality' do
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:change_issue_confidentiality)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.change_issue_confidentiality(noteable, project, author)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.change_branch' do
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'calls MergeRequestsService' do
|
2021-03-11 19:13:27 +05:30
|
|
|
old_branch = double('old_branch')
|
|
|
|
new_branch = double('new_branch')
|
|
|
|
branch_type = double('branch_type')
|
|
|
|
event_type = double('event_type')
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(service).to receive(:change_branch).with(branch_type, event_type, old_branch, new_branch)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
described_class.change_branch(noteable, project, author, branch_type, event_type, old_branch, new_branch)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-10-24 18:46:33 +05:30
|
|
|
describe '.change_branch_presence' do
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
presence = double
|
|
|
|
branch = double
|
|
|
|
branch_type = double
|
2015-10-24 18:46:33 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
|
|
|
expect(service).to receive(:change_branch_presence).with(branch_type, branch, presence)
|
2015-10-24 18:46:33 +05:30
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
described_class.change_branch_presence(noteable, project, author, branch_type, branch, presence)
|
2015-10-24 18:46:33 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
describe '.new_issue_branch' do
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
branch = double
|
|
|
|
branch_project = double
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
|
|
|
expect(service).to receive(:new_issue_branch).with(branch, branch_project: branch_project)
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
described_class.new_issue_branch(noteable, project, author, branch, branch_project: branch_project)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
describe '.new_merge_request' do
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
merge_request = double
|
2019-02-15 15:39:39 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
|
|
|
expect(service).to receive(:new_merge_request).with(merge_request)
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
described_class.new_merge_request(noteable, project, author, merge_request)
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
describe '.zoom_link_added' do
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls ZoomService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::ZoomService) do |service|
|
|
|
|
expect(service).to receive(:zoom_link_added)
|
|
|
|
end
|
2019-10-12 21:52:04 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.zoom_link_added(noteable, project, author)
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.zoom_link_removed' do
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls ZoomService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::ZoomService) do |service|
|
|
|
|
expect(service).to receive(:zoom_link_removed)
|
|
|
|
end
|
2019-10-12 21:52:04 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.zoom_link_removed(noteable, project, author)
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
describe '.cross_reference' do
|
2022-01-26 12:08:38 +05:30
|
|
|
let(:mentioned_in) { double }
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
2022-01-26 12:08:38 +05:30
|
|
|
expect(service).to receive(:cross_reference).with(mentioned_in)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
described_class.cross_reference(double, mentioned_in, double)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.cross_reference_disallowed?' do
|
2022-01-26 12:08:38 +05:30
|
|
|
let(:mentioned_in) { double }
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
2022-01-26 12:08:38 +05:30
|
|
|
expect(service).to receive(:cross_reference_disallowed?).with(mentioned_in)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
described_class.cross_reference_disallowed?(double, mentioned_in)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.cross_reference_exists?' do
|
2022-01-26 12:08:38 +05:30
|
|
|
let(:mentioned_in) { double }
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
2022-01-26 12:08:38 +05:30
|
|
|
expect(service).to receive(:cross_reference_exists?).with(mentioned_in)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
described_class.cross_reference_exists?(double, mentioned_in)
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
describe '.noteable_moved' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:noteable_ref) { double }
|
|
|
|
let(:direction) { double }
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:noteable_moved).with(noteable_ref, direction)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.noteable_moved(double, double, noteable_ref, double, direction: direction)
|
2021-02-22 17:27:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.noteable_cloned' do
|
|
|
|
let(:noteable_ref) { double }
|
|
|
|
let(:direction) { double }
|
|
|
|
|
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:noteable_cloned).with(noteable_ref, direction)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.noteable_cloned(double, double, noteable_ref, double, direction: direction)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
describe '.change_time_estimate' do
|
2020-03-13 15:44:24 +05:30
|
|
|
it 'calls TimeTrackingService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::TimeTrackingService) do |service|
|
|
|
|
expect(service).to receive(:change_time_estimate)
|
2019-07-31 22:56:46 +05:30
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
described_class.change_time_estimate(noteable, project, author)
|
2019-07-31 22:56:46 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
describe '.discussion_continued_in_issue' do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:discussion) { create(:diff_note_on_merge_request, project: project).to_discussion }
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:merge_request) { discussion.noteable }
|
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
|
|
|
|
def reloaded_merge_request
|
|
|
|
MergeRequest.find(merge_request.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { described_class.discussion_continued_in_issue(discussion, project, author, issue) }
|
|
|
|
|
|
|
|
it_behaves_like 'a system note' do
|
|
|
|
let(:expected_noteable) { discussion.first_note.noteable }
|
|
|
|
let(:action) { 'discussion' }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a new note in the discussion' do
|
|
|
|
# we need to completely rebuild the merge request object, or the `@discussions` on the merge request are not reloaded.
|
|
|
|
expect { subject }.to change { reloaded_merge_request.discussions.first.notes.size }.by(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'mentions the created issue in the system note' do
|
|
|
|
expect(subject.note).to include(issue.to_reference)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.change_time_spent' do
|
2020-03-13 15:44:24 +05:30
|
|
|
it 'calls TimeTrackingService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::TimeTrackingService) do |service|
|
|
|
|
expect(service).to receive(:change_time_spent)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
described_class.change_time_spent(noteable, project, author)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
describe '.handle_merge_request_draft' do
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
2021-01-29 00:20:46 +05:30
|
|
|
expect(service).to receive(:handle_merge_request_draft)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
described_class.handle_merge_request_draft(noteable, project, author)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
describe '.add_merge_request_draft_from_commit' do
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
commit = double
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
2021-01-29 00:20:46 +05:30
|
|
|
expect(service).to receive(:add_merge_request_draft_from_commit).with(commit)
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
described_class.add_merge_request_draft_from_commit(noteable, project, author, commit)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.change_task_status' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:new_task) { double }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:change_task_status).with(new_task)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.change_task_status(noteable, project, author, new_task)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.resolve_all_discussions' do
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
|
|
|
expect(service).to receive(:resolve_all_discussions)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
described_class.resolve_all_discussions(noteable, project, author)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
describe '.diff_discussion_outdated' do
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
discussion = double
|
|
|
|
change_position = double
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
|
|
|
expect(service).to receive(:diff_discussion_outdated).with(discussion, change_position)
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
described_class.diff_discussion_outdated(discussion, project, author, change_position)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.mark_duplicate_issue' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:canonical_issue) { double }
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:mark_duplicate_issue).with(canonical_issue)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.mark_duplicate_issue(noteable, project, author, canonical_issue)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.mark_canonical_issue_of_duplicate' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:duplicate_issue) { double }
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:mark_canonical_issue_of_duplicate).with(duplicate_issue)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.mark_canonical_issue_of_duplicate(noteable, project, author, duplicate_issue)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
describe '.discussion_lock' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:issuable) { double }
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
before do
|
|
|
|
allow(issuable).to receive(:project).and_return(double)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:discussion_lock)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
described_class.discussion_lock(issuable, double)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
describe '.auto_resolve_prometheus_alert' do
|
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:auto_resolve_prometheus_alert)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.auto_resolve_prometheus_alert(noteable, project, author)
|
|
|
|
end
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
describe '.design_version_added' do
|
|
|
|
let(:version) { create(:design_version) }
|
|
|
|
|
|
|
|
it 'calls DesignManagementService' do
|
|
|
|
expect_next_instance_of(SystemNotes::DesignManagementService) do |service|
|
|
|
|
expect(service).to receive(:design_version_added).with(version)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.design_version_added(version)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.design_discussion_added' do
|
|
|
|
let(:discussion_note) { create(:diff_note_on_design) }
|
|
|
|
|
|
|
|
it 'calls DesignManagementService' do
|
|
|
|
expect_next_instance_of(SystemNotes::DesignManagementService) do |service|
|
|
|
|
expect(service).to receive(:design_discussion_added).with(discussion_note)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.design_discussion_added(discussion_note)
|
|
|
|
end
|
|
|
|
end
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
describe '.approve_mr' do
|
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
|
|
|
expect(service).to receive(:approve_mr)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.approve_mr(noteable, author)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.unapprove_mr' do
|
|
|
|
it 'calls MergeRequestsService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::MergeRequestsService) do |service|
|
|
|
|
expect(service).to receive(:unapprove_mr)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.unapprove_mr(noteable, author)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.change_alert_status' do
|
|
|
|
let(:alert) { build(:alert_management_alert) }
|
|
|
|
|
|
|
|
it 'calls AlertManagementService' do
|
|
|
|
expect_next_instance_of(SystemNotes::AlertManagementService) do |service|
|
|
|
|
expect(service).to receive(:change_alert_status).with(alert)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.change_alert_status(alert, author)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.new_alert_issue' do
|
2021-10-27 15:23:28 +05:30
|
|
|
let(:alert) { build(:alert_management_alert, :with_incident) }
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
it 'calls AlertManagementService' do
|
|
|
|
expect_next_instance_of(SystemNotes::AlertManagementService) do |service|
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(service).to receive(:new_alert_issue).with(alert.issue)
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
described_class.new_alert_issue(alert, alert.issue, author)
|
|
|
|
end
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
describe '.create_new_alert' do
|
|
|
|
let(:alert) { build(:alert_management_alert) }
|
|
|
|
let(:monitoring_tool) { 'Prometheus' }
|
|
|
|
|
|
|
|
it 'calls AlertManagementService' do
|
|
|
|
expect_next_instance_of(SystemNotes::AlertManagementService) do |service|
|
|
|
|
expect(service).to receive(:create_new_alert).with(monitoring_tool)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.create_new_alert(alert, monitoring_tool)
|
|
|
|
end
|
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
describe '.change_incident_severity' do
|
|
|
|
let(:incident) { build(:incident) }
|
|
|
|
|
|
|
|
it 'calls IncidentService' do
|
|
|
|
expect_next_instance_of(SystemNotes::IncidentService) do |service|
|
|
|
|
expect(service).to receive(:change_incident_severity)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.change_incident_severity(incident, author)
|
|
|
|
end
|
|
|
|
end
|
2021-04-17 20:07:23 +05:30
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
describe '.resolve_incident_status' do
|
|
|
|
let(:incident) { build(:incident, :closed) }
|
|
|
|
|
|
|
|
it 'calls IncidentService' do
|
|
|
|
expect_next_instance_of(SystemNotes::IncidentService) do |service|
|
|
|
|
expect(service).to receive(:resolve_incident_status)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.resolve_incident_status(incident, author)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
describe '.log_resolving_alert' do
|
|
|
|
let(:alert) { build(:alert_management_alert) }
|
|
|
|
let(:monitoring_tool) { 'Prometheus' }
|
|
|
|
|
|
|
|
it 'calls AlertManagementService' do
|
|
|
|
expect_next_instance_of(SystemNotes::AlertManagementService) do |service|
|
|
|
|
expect(service).to receive(:log_resolving_alert).with(monitoring_tool)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.log_resolving_alert(alert, monitoring_tool)
|
|
|
|
end
|
|
|
|
end
|
2021-11-11 11:23:49 +05:30
|
|
|
|
|
|
|
describe '.change_issue_type' do
|
|
|
|
let(:incident) { build(:incident) }
|
|
|
|
|
|
|
|
it 'calls IssuableService' do
|
|
|
|
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
|
|
|
|
expect(service).to receive(:change_issue_type)
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.change_issue_type(incident, author)
|
|
|
|
end
|
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|