diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/services/issues | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) | |
download | gitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/services/issues')
-rw-r--r-- | spec/services/issues/close_service_spec.rb | 27 | ||||
-rw-r--r-- | spec/services/issues/export_csv_service_spec.rb | 4 |
2 files changed, 20 insertions, 11 deletions
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index 9076fb11c9b..dc545f57d23 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -112,10 +112,14 @@ RSpec.describe Issues::CloseService do end context "closed by a merge request", :sidekiq_might_not_need_inline do - it 'mentions closure via a merge request' do + subject(:close_issue) do perform_enqueued_jobs do described_class.new(project, user).close_issue(issue, closed_via: closing_merge_request) end + end + + it 'mentions closure via a merge request' do + close_issue email = ActionMailer::Base.deliveries.last @@ -124,12 +128,15 @@ RSpec.describe Issues::CloseService do expect(email.body.parts.map(&:body)).to all(include(closing_merge_request.to_reference)) end + it_behaves_like 'records an onboarding progress action', :issue_auto_closed do + let(:namespace) { project.namespace } + end + context 'when user cannot read merge request' do it 'does not mention merge request' do project.project_feature.update_attribute(:repository_access_level, ProjectFeature::DISABLED) - perform_enqueued_jobs do - described_class.new(project, user).close_issue(issue, closed_via: closing_merge_request) - end + + close_issue email = ActionMailer::Base.deliveries.last body_text = email.body.parts.map(&:body).join(" ") @@ -141,13 +148,11 @@ RSpec.describe Issues::CloseService do end context 'updating `metrics.first_mentioned_in_commit_at`' do - subject { described_class.new(project, user).close_issue(issue, closed_via: closing_merge_request) } - context 'when `metrics.first_mentioned_in_commit_at` is not set' do it 'uses the first commit authored timestamp' do expected = closing_merge_request.commits.first.authored_date - subject + close_issue expect(issue.metrics.first_mentioned_in_commit_at).to eq(expected) end @@ -159,7 +164,7 @@ RSpec.describe Issues::CloseService do end it 'does not update the metrics' do - expect { subject }.not_to change { issue.metrics.first_mentioned_in_commit_at } + expect { close_issue }.not_to change { issue.metrics.first_mentioned_in_commit_at } end end @@ -167,7 +172,7 @@ RSpec.describe Issues::CloseService do let(:closing_merge_request) { create(:merge_request, :without_diffs, source_project: project) } it 'does not update the metrics' do - subject + close_issue expect(issue.metrics.first_mentioned_in_commit_at).to be_nil end @@ -206,7 +211,7 @@ RSpec.describe Issues::CloseService do end context "valid params" do - def close_issue + subject(:close_issue) do perform_enqueued_jobs do described_class.new(project, user).close_issue(issue) end @@ -290,6 +295,8 @@ RSpec.describe Issues::CloseService do close_issue end + + it_behaves_like 'does not record an onboarding progress action' end context 'when issue is not confidential' do diff --git a/spec/services/issues/export_csv_service_spec.rb b/spec/services/issues/export_csv_service_spec.rb index 8072b7a478e..fd1bcf82ccd 100644 --- a/spec/services/issues/export_csv_service_spec.rb +++ b/spec/services/issues/export_csv_service_spec.rb @@ -20,7 +20,9 @@ RSpec.describe Issues::ExportCsvService do end it 'renders with a target filesize' do - expect(subject.csv_builder).to receive(:render).with(described_class::TARGET_FILESIZE) + expect_next_instance_of(CsvBuilder) do |csv_builder| + expect(csv_builder).to receive(:render).with(described_class::TARGET_FILESIZE).once + end subject.email(user) end |