diff options
Diffstat (limited to 'spec/graphql/mutations/issues/update_spec.rb')
-rw-r--r-- | spec/graphql/mutations/issues/update_spec.rb | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/spec/graphql/mutations/issues/update_spec.rb b/spec/graphql/mutations/issues/update_spec.rb index f10e257e153..6d6a5b94219 100644 --- a/spec/graphql/mutations/issues/update_spec.rb +++ b/spec/graphql/mutations/issues/update_spec.rb @@ -69,17 +69,33 @@ RSpec.describe Mutations::Issues::Update do context 'when changing state' do let_it_be_with_refind(:issue) { create(:issue, project: project, state: :opened) } - it 'closes issue' do - mutation_params[:state_event] = 'close' + before do + mutation_params[:state_event] = state_event + end + + context 'when state_event is close' do + let_it_be(:removable_label) { create(:label, project: project, remove_on_close: true, issues: [issue]) } - expect { subject }.to change { issue.reload.state }.from('opened').to('closed') + let(:state_event) { 'close' } + + it 'closes issue' do + expect do + subject + issue.reload + end.to change(issue, :state).from('opened').to('closed').and( + change { issue.label_ids }.from([removable_label.id]).to([]) + ) + end end - it 'reopens issue' do - issue.close - mutation_params[:state_event] = 'reopen' + context 'when state_event is reopen' do + let(:state_event) { 'reopen' } + + it 'reopens issue' do + issue.close - expect { subject }.to change { issue.reload.state }.from('closed').to('opened') + expect { subject }.to change { issue.reload.state }.from('closed').to('opened') + end end end @@ -128,6 +144,14 @@ RSpec.describe Mutations::Issues::Update do expect(issue.reload.labels).to match_array([project_label, label_2]) end end + + context 'when changing type' do + it 'changes the type of the issue' do + mutation_params[:issue_type] = 'incident' + + expect { subject }.to change { issue.reload.issue_type }.from('issue').to('incident') + end + end end end end |