diff options
Diffstat (limited to 'spec/services/issues/update_service_spec.rb')
-rw-r--r-- | spec/services/issues/update_service_spec.rb | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 29ac7df88eb..331cf291f21 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -146,8 +146,11 @@ RSpec.describe Issues::UpdateService, :mailer do 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. - expect { update_issue(confidential: true) } - .to change { project.open_issues_count }.from(1).to(0) + expect do + update_issue(confidential: true) + + BatchLoader::Executor.clear_current + end.to change { project.open_issues_count }.from(1).to(0) end it 'enqueues ConfidentialIssueWorker when an issue is made confidential' do @@ -189,6 +192,14 @@ RSpec.describe Issues::UpdateService, :mailer do expect(issue.labels.pluck(:title)).to eq(['incident']) end + it 'creates system note about issue type' do + update_issue(issue_type: 'incident') + + note = find_note('changed issue type to incident') + + expect(note).not_to eq(nil) + end + context 'for an issue with multiple labels' do let(:issue) { create(:incident, project: project, labels: [label_1]) } @@ -217,15 +228,19 @@ RSpec.describe Issues::UpdateService, :mailer do context 'from incident to issue' do let(:issue) { create(:incident, project: project) } + it 'changed from an incident to an issue type' do + expect { update_issue(issue_type: 'issue') } + .to change(issue, :issue_type).from('incident').to('issue') + .and(change { issue.work_item_type.base_type }.from('incident').to('issue')) + end + context 'for an incident with multiple labels' do let(:issue) { create(:incident, project: project, labels: [label_1, label_2]) } - before do - update_issue(issue_type: 'issue') - end - it 'removes an `incident` label if one exists on the incident' do - expect(issue.labels).to eq([label_2]) + expect { update_issue(issue_type: 'issue') }.to change(issue, :label_ids) + .from(containing_exactly(label_1.id, label_2.id)) + .to([label_2.id]) end end @@ -233,12 +248,10 @@ RSpec.describe Issues::UpdateService, :mailer do let(:issue) { create(:incident, project: project, labels: [label_1, label_2]) } let(:params) { { label_ids: [label_1.id, label_2.id], remove_label_ids: [] } } - before do - update_issue(issue_type: 'issue') - end - it 'adds an incident label id to remove_label_ids for it to be removed' do - expect(issue.label_ids).to contain_exactly(label_2.id) + expect { update_issue(issue_type: 'issue') }.to change(issue, :label_ids) + .from(containing_exactly(label_1.id, label_2.id)) + .to([label_2.id]) end end end |