diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/services/issues | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) | |
download | gitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/services/issues')
-rw-r--r-- | spec/services/issues/close_service_spec.rb | 11 | ||||
-rw-r--r-- | spec/services/issues/create_service_spec.rb | 83 | ||||
-rw-r--r-- | spec/services/issues/duplicate_service_spec.rb | 11 | ||||
-rw-r--r-- | spec/services/issues/export_csv_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/issues/move_service_spec.rb | 74 | ||||
-rw-r--r-- | spec/services/issues/related_branches_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/issues/reopen_service_spec.rb | 11 | ||||
-rw-r--r-- | spec/services/issues/reorder_service_spec.rb | 34 | ||||
-rw-r--r-- | spec/services/issues/resolve_discussions_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/issues/update_service_spec.rb | 179 | ||||
-rw-r--r-- | spec/services/issues/zoom_link_service_spec.rb | 7 |
11 files changed, 362 insertions, 56 deletions
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index 7ca7d3be99c..4db6e5cac12 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -67,6 +67,15 @@ RSpec.describe Issues::CloseService do service.execute(issue) end + + context 'issue is incident type' do + let(:issue) { create(:incident, project: project) } + let(:current_user) { user } + + subject { service.execute(issue) } + + it_behaves_like 'an incident management tracked event', :incident_management_incident_closed + end end describe '#close_issue' do @@ -288,7 +297,7 @@ RSpec.describe Issues::CloseService do end it 'deletes milestone issue counters cache' do - issue.update(milestone: create(:milestone, project: project)) + issue.update!(milestone: create(:milestone, project: project)) expect_next_instance_of(Milestones::ClosedIssuesCountService, issue.milestone) do |service| expect(service).to receive(:delete_cache).and_call_original diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index fdf2326b75e..e09a7faece5 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -3,18 +3,18 @@ require 'spec_helper' RSpec.describe Issues::CreateService do - let(:project) { create(:project) } - let(:user) { create(:user) } + let_it_be_with_reload(:project) { create(:project) } + let_it_be(:user) { create(:user) } describe '#execute' do + let_it_be(:assignee) { create(:user) } + let_it_be(:milestone) { create(:milestone, project: project) } let(:issue) { described_class.new(project, user, opts).execute } - let(:assignee) { create(:user) } - let(:milestone) { create(:milestone, project: project) } context 'when params are valid' do - let(:labels) { create_pair(:label, project: project) } + let_it_be(:labels) { create_pair(:label, project: project) } - before do + before_all do project.add_maintainer(user) project.add_maintainer(assignee) end @@ -29,6 +29,8 @@ RSpec.describe Issues::CreateService do end it 'creates the issue with the given params' do + expect(Issuable::CommonSystemNotesService).to receive_message_chain(:new, :execute) + expect(issue).to be_persisted expect(issue.title).to eq('Awesome issue') expect(issue.assignees).to eq [assignee] @@ -37,14 +39,55 @@ RSpec.describe Issues::CreateService do expect(issue.due_date).to eq Date.tomorrow end + context 'when skip_system_notes is true' do + let(:issue) { described_class.new(project, user, opts).execute(skip_system_notes: true) } + + it 'does not call Issuable::CommonSystemNotesService' do + expect(Issuable::CommonSystemNotesService).not_to receive(:new) + + issue + end + end + + it_behaves_like 'not an incident issue' + + context 'issue is incident type' do + before do + opts.merge!(issue_type: 'incident') + end + + let(:current_user) { user } + let(:incident_label_attributes) { attributes_for(:label, :incident) } + + subject { issue } + + it_behaves_like 'incident issue' + it_behaves_like 'an incident management tracked event', :incident_management_incident_created + + it 'does create an incident label' do + expect { subject } + .to change { Label.where(incident_label_attributes).count }.by(1) + end + + context 'when invalid' do + before do + opts.merge!(title: '') + end + + it 'does not create an incident label prematurely' do + expect { subject }.not_to change(Label, :count) + end + end + end + it 'refreshes the number of open issues', :use_clean_rails_memory_store_caching do expect { issue }.to change { project.open_issues_count }.from(0).to(1) end context 'when current user cannot admin issues in the project' do - let(:guest) { create(:user) } + let_it_be(:guest) { create(:user) } - before do + before_all do project.add_guest(guest) end @@ -75,6 +118,12 @@ RSpec.describe Issues::CreateService do expect(Todo.where(attributes).count).to eq 1 end + it 'moves the issue to the end, in an asynchronous worker' do + expect(IssuePlacementWorker).to receive(:perform_async).with(be_nil, Integer) + + described_class.new(project, user, opts).execute + end + context 'when label belongs to project group' do let(:group) { create(:group) } let(:group_labels) { create_pair(:group_label, group: group) } @@ -88,7 +137,7 @@ RSpec.describe Issues::CreateService do end before do - project.update(group: group) + project.update!(group: group) end it 'assigns group labels' do @@ -233,7 +282,7 @@ RSpec.describe Issues::CreateService do context 'issue create service' do context 'assignees' do - before do + before_all do project.add_maintainer(user) end @@ -264,7 +313,7 @@ RSpec.describe Issues::CreateService do context "when issuable feature is private" do before do - project.project_feature.update(issues_access_level: ProjectFeature::PRIVATE, + project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE, merge_requests_access_level: ProjectFeature::PRIVATE) end @@ -272,7 +321,7 @@ RSpec.describe Issues::CreateService do levels.each do |level| it "removes not authorized assignee when project is #{Gitlab::VisibilityLevel.level_name(level)}" do - project.update(visibility_level: level) + project.update!(visibility_level: level) opts = { title: 'Title', description: 'Description', assignee_ids: [assignee.id] } issue = described_class.new(project, user, opts).execute @@ -299,7 +348,7 @@ RSpec.describe Issues::CreateService do } end - before do + before_all do project.add_maintainer(user) project.add_maintainer(assignee) end @@ -313,11 +362,11 @@ RSpec.describe Issues::CreateService do end context 'resolving discussions' do - let(:discussion) { create(:diff_note_on_merge_request).to_discussion } - let(:merge_request) { discussion.noteable } - let(:project) { merge_request.source_project } + let_it_be(:discussion) { create(:diff_note_on_merge_request).to_discussion } + let_it_be(:merge_request) { discussion.noteable } + let_it_be(:project) { merge_request.source_project } - before do + before_all do project.add_maintainer(user) end diff --git a/spec/services/issues/duplicate_service_spec.rb b/spec/services/issues/duplicate_service_spec.rb index 78e030e6ac7..0b5bc3f32ef 100644 --- a/spec/services/issues/duplicate_service_spec.rb +++ b/spec/services/issues/duplicate_service_spec.rb @@ -83,6 +83,17 @@ RSpec.describe Issues::DuplicateService do expect(duplicate_issue.reload.duplicated_to).to eq(canonical_issue) end + + it 'relates the duplicate issues' do + canonical_project.add_reporter(user) + duplicate_project.add_reporter(user) + + subject.execute(duplicate_issue, canonical_issue) + + issue_link = IssueLink.last + expect(issue_link.source).to eq(duplicate_issue) + expect(issue_link.target).to eq(canonical_issue) + end end end end diff --git a/spec/services/issues/export_csv_service_spec.rb b/spec/services/issues/export_csv_service_spec.rb index 76381fe525b..8072b7a478e 100644 --- a/spec/services/issues/export_csv_service_spec.rb +++ b/spec/services/issues/export_csv_service_spec.rb @@ -38,8 +38,8 @@ RSpec.describe Issues::ExportCsvService do before do # Creating a timelog touches the updated_at timestamp of issue, # so create these first. - issue.timelogs.create(time_spent: 360, user: user) - issue.timelogs.create(time_spent: 200, user: user) + issue.timelogs.create!(time_spent: 360, user: user) + issue.timelogs.create!(time_spent: 200, user: user) issue.update!(milestone: milestone, assignees: [user], description: 'Issue with details', diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index 5f944d1213b..c2989dc86cf 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -101,6 +101,41 @@ RSpec.describe Issues::MoveService do end end + context 'issue with milestone' do + let(:milestone) { create(:milestone, group: sub_group_1) } + let(:new_project) { create(:project, namespace: sub_group_1) } + + let(:old_issue) do + create(:issue, title: title, description: description, project: old_project, author: author, milestone: milestone) + end + + before do + create(:resource_milestone_event, issue: old_issue, milestone: milestone, action: :add) + end + + it 'does not create extra milestone events' do + new_issue = move_service.execute(old_issue, new_project) + + expect(new_issue.resource_milestone_events.count).to eq(old_issue.resource_milestone_events.count) + end + end + + context 'issue with due date' do + let(:old_issue) do + create(:issue, title: title, description: description, project: old_project, author: author, due_date: '2020-01-10') + end + + before do + SystemNoteService.change_due_date(old_issue, old_project, author, old_issue.due_date) + end + + it 'does not create extra system notes' do + new_issue = move_service.execute(old_issue, new_project) + + expect(new_issue.notes.count).to eq(old_issue.notes.count) + end + end + context 'issue with assignee' do let_it_be(:assignee) { create(:user) } @@ -223,6 +258,45 @@ RSpec.describe Issues::MoveService do end end + describe '#rewrite_related_issues' do + include_context 'user can move issue' + + let(:admin) { create(:admin) } + let(:authorized_project) { create(:project) } + let(:authorized_project2) { create(:project) } + let(:unauthorized_project) { create(:project) } + + let(:authorized_issue_b) { create(:issue, project: authorized_project) } + let(:authorized_issue_c) { create(:issue, project: authorized_project2) } + let(:authorized_issue_d) { create(:issue, project: authorized_project2) } + let(:unauthorized_issue) { create(:issue, project: unauthorized_project) } + + let!(:issue_link_a) { create(:issue_link, source: old_issue, target: authorized_issue_b) } + let!(:issue_link_b) { create(:issue_link, source: old_issue, target: unauthorized_issue) } + let!(:issue_link_c) { create(:issue_link, source: old_issue, target: authorized_issue_c) } + let!(:issue_link_d) { create(:issue_link, source: authorized_issue_d, target: old_issue) } + + before do + authorized_project.add_developer(user) + authorized_project2.add_developer(user) + end + + context 'multiple related issues' do + it 'moves all related issues and retains permissions' do + new_issue = move_service.execute(old_issue, new_project) + + expect(new_issue.related_issues(admin)) + .to match_array([authorized_issue_b, authorized_issue_c, authorized_issue_d, unauthorized_issue]) + + expect(new_issue.related_issues(user)) + .to match_array([authorized_issue_b, authorized_issue_c, authorized_issue_d]) + + expect(authorized_issue_d.related_issues(user)) + .to match_array([new_issue]) + end + end + end + context 'updating sent notifications' do let!(:old_issue_notification_1) { create(:sent_notification, project: old_issue.project, noteable: old_issue) } let!(:old_issue_notification_2) { create(:sent_notification, project: old_issue.project, noteable: old_issue) } diff --git a/spec/services/issues/related_branches_service_spec.rb b/spec/services/issues/related_branches_service_spec.rb index d79132d98db..1780023803a 100644 --- a/spec/services/issues/related_branches_service_spec.rb +++ b/spec/services/issues/related_branches_service_spec.rb @@ -57,7 +57,7 @@ RSpec.describe Issues::RelatedBranchesService do unreadable_branch_name => unreadable_pipeline }.each do |name, pipeline| allow(repo).to receive(:find_branch).with(name).and_return(make_branch) - allow(project).to receive(:pipeline_for).with(name, sha).and_return(pipeline) + allow(project).to receive(:latest_pipeline).with(name, sha).and_return(pipeline) end allow(repo).to receive(:find_branch).with(missing_branch).and_return(nil) diff --git a/spec/services/issues/reopen_service_spec.rb b/spec/services/issues/reopen_service_spec.rb index f7416203259..ffe74cca9cf 100644 --- a/spec/services/issues/reopen_service_spec.rb +++ b/spec/services/issues/reopen_service_spec.rb @@ -44,7 +44,7 @@ RSpec.describe Issues::ReopenService do end it 'deletes milestone issue counters cache' do - issue.update(milestone: create(:milestone, project: project)) + issue.update!(milestone: create(:milestone, project: project)) expect_next_instance_of(Milestones::ClosedIssuesCountService, issue.milestone) do |service| expect(service).to receive(:delete_cache).and_call_original @@ -53,6 +53,15 @@ RSpec.describe Issues::ReopenService do described_class.new(project, user).execute(issue) end + context 'issue is incident type' do + let(:issue) { create(:incident, :closed, project: project) } + let(:current_user) { user } + + subject { described_class.new(project, user).execute(issue) } + + it_behaves_like 'an incident management tracked event', :incident_management_incident_reopened + end + context 'when issue is not confidential' do it 'executes issue hooks' do expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks) diff --git a/spec/services/issues/reorder_service_spec.rb b/spec/services/issues/reorder_service_spec.rb index b6ad488a48c..78b937a1caf 100644 --- a/spec/services/issues/reorder_service_spec.rb +++ b/spec/services/issues/reorder_service_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' RSpec.describe Issues::ReorderService do - let_it_be(:user) { create(:user) } - let_it_be(:project) { create(:project) } + let_it_be(:user) { create_default(:user) } let_it_be(:group) { create(:group) } + let_it_be(:project, reload: true) { create(:project, namespace: group) } shared_examples 'issues reorder service' do context 'when reordering issues' do @@ -14,7 +14,7 @@ RSpec.describe Issues::ReorderService do end it 'returns false with both invalid params' do - params = { move_after_id: nil, move_before_id: 1 } + params = { move_after_id: nil, move_before_id: non_existing_record_id } expect(service(params).execute(issue1)).to be_falsey end @@ -27,27 +27,39 @@ RSpec.describe Issues::ReorderService do expect(issue1.relative_position) .to be_between(issue2.relative_position, issue3.relative_position) end + + it 'sorts issues if only given one neighbour, on the left' do + params = { move_before_id: issue3.id } + + service(params).execute(issue1) + + expect(issue1.relative_position).to be > issue3.relative_position + end + + it 'sorts issues if only given one neighbour, on the right' do + params = { move_after_id: issue1.id } + + service(params).execute(issue3) + + expect(issue3.relative_position).to be < issue1.relative_position + end end end describe '#execute' do - let(:issue1) { create(:issue, project: project, relative_position: 10) } - let(:issue2) { create(:issue, project: project, relative_position: 20) } - let(:issue3) { create(:issue, project: project, relative_position: 30) } + let_it_be(:issue1, reload: true) { create(:issue, project: project, relative_position: 10) } + let_it_be(:issue2) { create(:issue, project: project, relative_position: 20) } + let_it_be(:issue3, reload: true) { create(:issue, project: project, relative_position: 30) } context 'when ordering issues in a project' do - let(:parent) { project } - before do - parent.add_developer(user) + project.add_developer(user) end it_behaves_like 'issues reorder service' end context 'when ordering issues in a group' do - let(:project) { create(:project, namespace: group) } - before do group.add_developer(user) end diff --git a/spec/services/issues/resolve_discussions_spec.rb b/spec/services/issues/resolve_discussions_spec.rb index a541d92feb2..9fbc9cbcca6 100644 --- a/spec/services/issues/resolve_discussions_spec.rb +++ b/spec/services/issues/resolve_discussions_spec.rb @@ -79,7 +79,7 @@ RSpec.describe Issues::ResolveDiscussions do noteable: merge_request, project: merge_request.target_project, line_number: 15 - )]) + )]) service = DummyService.new( project, user, diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 42452e95f6b..f0092c35fda 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -52,7 +52,8 @@ RSpec.describe Issues::UpdateService, :mailer do state_event: 'close', label_ids: [label.id], due_date: Date.tomorrow, - discussion_locked: true + discussion_locked: true, + severity: 'low' } end @@ -71,6 +72,51 @@ RSpec.describe Issues::UpdateService, :mailer do expect(issue.discussion_locked).to be_truthy end + context 'when issue type is not incident' do + it 'returns default severity' do + update_issue(opts) + + expect(issue.severity).to eq(IssuableSeverity::DEFAULT) + end + + it_behaves_like 'not an incident issue' do + before do + update_issue(opts) + end + end + end + + context 'when issue type is incident' do + let(:issue) { create(:incident, project: project) } + + it 'changes updates the severity' do + update_issue(opts) + + expect(issue.severity).to eq('low') + end + + it_behaves_like 'incident issue' do + before do + update_issue(opts) + end + end + + context 'with existing incident label' do + let_it_be(:incident_label) { create(:label, :incident, project: project) } + + before do + opts.delete(:label_ids) # don't override but retain existing labels + issue.labels << incident_label + end + + it_behaves_like 'incident issue' do + before do + update_issue(opts) + end + end + end + end + it 'refreshes the number of open issues when the issue is made confidential', :use_clean_rails_memory_store_caching do issue # make sure the issue is created first so our counts are correct. @@ -93,6 +139,40 @@ RSpec.describe Issues::UpdateService, :mailer do update_issue(confidential: false) end + context 'issue in incident type' do + let(:current_user) { user } + let(:incident_label_attributes) { attributes_for(:label, :incident) } + + before do + opts.merge!(issue_type: 'incident', confidential: true) + end + + subject { update_issue(opts) } + + it_behaves_like 'an incident management tracked event', :incident_management_incident_change_confidential + + it_behaves_like 'incident issue' do + before do + subject + end + end + + it 'does create an incident label' do + expect { subject } + .to change { Label.where(incident_label_attributes).count }.by(1) + end + + context 'when invalid' do + before do + opts.merge!(title: '') + end + + it 'does not create an incident label prematurely' do + expect { subject }.not_to change(Label, :count) + end + end + end + it 'updates open issue counter for assignees when issue is reassigned' do update_issue(assignee_ids: [user2.id]) @@ -106,7 +186,7 @@ RSpec.describe Issues::UpdateService, :mailer do [issue, issue1, issue2].each do |issue| issue.move_to_end - issue.save + issue.save! end opts[:move_between_ids] = [issue1.id, issue2.id] @@ -116,6 +196,66 @@ RSpec.describe Issues::UpdateService, :mailer do expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position) end + it 'does not rebalance even if needed if the flag is disabled' do + stub_feature_flags(rebalance_issues: false) + + range = described_class::NO_REBALANCING_NEEDED + issue1 = create(:issue, project: project, relative_position: range.first - 100) + issue2 = create(:issue, project: project, relative_position: range.first) + issue.update!(relative_position: RelativePositioning::START_POSITION) + + opts[:move_between_ids] = [issue1.id, issue2.id] + + expect(IssueRebalancingWorker).not_to receive(:perform_async) + + update_issue(opts) + expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position) + end + + it 'rebalances if needed if the flag is enabled for the project' do + stub_feature_flags(rebalance_issues: project) + + range = described_class::NO_REBALANCING_NEEDED + issue1 = create(:issue, project: project, relative_position: range.first - 100) + issue2 = create(:issue, project: project, relative_position: range.first) + issue.update!(relative_position: RelativePositioning::START_POSITION) + + opts[:move_between_ids] = [issue1.id, issue2.id] + + expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, project.id) + + update_issue(opts) + expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position) + end + + it 'rebalances if needed on the left' do + range = described_class::NO_REBALANCING_NEEDED + issue1 = create(:issue, project: project, relative_position: range.first - 100) + issue2 = create(:issue, project: project, relative_position: range.first) + issue.update!(relative_position: RelativePositioning::START_POSITION) + + opts[:move_between_ids] = [issue1.id, issue2.id] + + expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, project.id) + + update_issue(opts) + expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position) + end + + it 'rebalances if needed on the right' do + range = described_class::NO_REBALANCING_NEEDED + issue1 = create(:issue, project: project, relative_position: range.last) + issue2 = create(:issue, project: project, relative_position: range.last + 100) + issue.update!(relative_position: RelativePositioning::START_POSITION) + + opts[:move_between_ids] = [issue1.id, issue2.id] + + expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, project.id) + + update_issue(opts) + expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position) + end + context 'when moving issue between issues from different projects' do let(:group) { create(:group) } let(:subgroup) { create(:group, parent: group) } @@ -294,7 +434,7 @@ RSpec.describe Issues::UpdateService, :mailer do end it 'does not update assignee_id with unauthorized users' do - project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) update_issue(confidential: true) non_member = create(:user) original_assignees = issue.assignees @@ -382,13 +522,16 @@ RSpec.describe Issues::UpdateService, :mailer do expect(Todo.where(attributes).count).to eq(1) end - end - context 'when the milestone is removed' do - before do - stub_feature_flags(track_resource_milestone_change_events: false) + context 'issue is incident type' do + let(:issue) { create(:incident, project: project) } + let(:current_user) { user } + + it_behaves_like 'an incident management tracked event', :incident_management_incident_assigned end + end + context 'when the milestone is removed' do let!(:non_subscriber) { create(:user) } let!(:subscriber) do @@ -398,12 +541,10 @@ RSpec.describe Issues::UpdateService, :mailer do end end - it_behaves_like 'system notes for milestones' - it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do issue.milestone = create(:milestone, project: project) - issue.save + issue.save! perform_enqueued_jobs do update_issue(milestone_id: "") @@ -416,7 +557,7 @@ RSpec.describe Issues::UpdateService, :mailer do it 'clears milestone issue counters cache' do issue.milestone = create(:milestone, project: project) - issue.save + issue.save! expect_next_instance_of(Milestones::IssuesCountService, issue.milestone) do |service| expect(service).to receive(:delete_cache).and_call_original @@ -430,10 +571,6 @@ RSpec.describe Issues::UpdateService, :mailer do end context 'when the milestone is assigned' do - before do - stub_feature_flags(track_resource_milestone_change_events: false) - end - let!(:non_subscriber) { create(:user) } let!(:subscriber) do @@ -449,8 +586,6 @@ RSpec.describe Issues::UpdateService, :mailer do expect(todo.reload.done?).to eq true end - it_behaves_like 'system notes for milestones' - it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do perform_enqueued_jobs do update_issue(milestone: create(:milestone, project: project)) @@ -670,7 +805,7 @@ RSpec.describe Issues::UpdateService, :mailer do let(:params) { { label_ids: [label.id], add_label_ids: [label3.id] } } before do - issue.update(labels: [label2]) + issue.update!(labels: [label2]) end it 'replaces the labels with the ones in label_ids and adds those in add_label_ids' do @@ -682,7 +817,7 @@ RSpec.describe Issues::UpdateService, :mailer do let(:params) { { label_ids: [label.id, label2.id, label3.id], remove_label_ids: [label.id] } } before do - issue.update(labels: [label, label3]) + issue.update!(labels: [label, label3]) end it 'replaces the labels with the ones in label_ids and removes those in remove_label_ids' do @@ -694,7 +829,7 @@ RSpec.describe Issues::UpdateService, :mailer do let(:params) { { add_label_ids: [label3.id], remove_label_ids: [label.id] } } before do - issue.update(labels: [label]) + issue.update!(labels: [label]) end it 'adds the passed labels' do @@ -711,7 +846,7 @@ RSpec.describe Issues::UpdateService, :mailer do context 'for a label assigned to an issue' do it 'removes the label' do - issue.update(labels: [label]) + issue.update!(labels: [label]) expect(result.label_ids).to be_empty end @@ -760,7 +895,7 @@ RSpec.describe Issues::UpdateService, :mailer do levels.each do |level| it "does not update with unauthorized assignee when project is #{Gitlab::VisibilityLevel.level_name(level)}" do assignee = create(:user) - project.update(visibility_level: level) + project.update!(visibility_level: level) feature_visibility_attr = :"#{issue.model_name.plural}_access_level" project.project_feature.update_attribute(feature_visibility_attr, ProjectFeature::PRIVATE) diff --git a/spec/services/issues/zoom_link_service_spec.rb b/spec/services/issues/zoom_link_service_spec.rb index 56aec4fe564..b095cb24212 100644 --- a/spec/services/issues/zoom_link_service_spec.rb +++ b/spec/services/issues/zoom_link_service_spec.rb @@ -82,6 +82,13 @@ RSpec.describe Issues::ZoomLinkService do include_examples 'can add meeting' + context 'issue is incident type' do + let(:issue) { create(:incident) } + let(:current_user) { user } + + it_behaves_like 'an incident management tracked event', :incident_management_incident_zoom_meeting + end + context 'with insufficient issue update permissions' do include_context 'insufficient issue update permissions' include_examples 'cannot add meeting' |