Welcome to mirror list, hosted at ThFree Co, Russian Federation.

set_escalation_status_spec.rb « issues « mutations « graphql « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f04d396efb8b4bc24b63ddf2638e674baa9dde1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Mutations::Issues::SetEscalationStatus do
  let_it_be(:user) { create(:user) }
  let_it_be(:project) { create(:project) }
  let_it_be(:issue, reload: true) { create(:incident, project: project) }
  let_it_be(:escalation_status, reload: true) { create(:incident_management_issuable_escalation_status, issue: issue) }

  let(:status) { :acknowledged }
  let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) }

  describe '#resolve' do
    let(:args) { { status: status } }
    let(:mutated_issue) { result[:issue] }

    subject(:result) { mutation.resolve(project_path: issue.project.full_path, iid: issue.iid, **args) }

    it_behaves_like 'permission level for issue mutation is correctly verified', true

    context 'when the user can update the issue' do
      before_all do
        project.add_reporter(user)
      end

      it_behaves_like 'permission level for issue mutation is correctly verified', true

      context 'when the user can update the escalation status' do
        before_all do
          project.add_developer(user)
        end

        it 'returns the issue with the escalation policy' do
          expect(mutated_issue).to eq(issue)
          expect(mutated_issue.escalation_status.status_name).to eq(status)
          expect(result[:errors]).to be_empty
        end

        it 'returns errors when issue update fails' do
          issue.update_column(:author_id, nil)

          expect(result[:errors]).not_to be_empty
        end

        context 'with non-incident issue is provided' do
          let_it_be(:issue) { create(:issue, project: project) }

          it 'raises an error' do
            expect { result }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature unavailable for provided issue')
          end
        end
      end
    end
  end
end