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

create_spec.rb « timeline_event_tag « incident_management « mutations « graphql « api « requests « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b37a533142157d0d0b95953a0aa339c3a3b97f01 (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
57
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Creating a timeline event tag', feature_category: :incident_management do
  include GraphqlHelpers

  let_it_be(:user) { create(:user) }
  let_it_be(:project) { create(:project) }
  let_it_be(:name) { 'Test tag 1' }

  let(:input) { { project_path: project.full_path, name: name } }
  let(:mutation) do
    graphql_mutation(:timeline_event_tag_create, input) do
      <<~QL
        clientMutationId
        errors
        timelineEventTag {
          id
          name
        }
      QL
    end
  end

  let(:mutation_response) { graphql_mutation_response(:timeline_event_tag_create) }

  context 'when user has permissions to create timeline event tag' do
    before do
      project.add_maintainer(user)
    end

    it 'creates timeline event tag', :aggregate_failures do
      post_graphql_mutation(mutation, current_user: user)

      timeline_event_tag_response = mutation_response['timelineEventTag']

      expect(response).to have_gitlab_http_status(:success)
      expect(timeline_event_tag_response).to include(
        'name' => name
      )
    end
  end

  context 'when user does not have permissions to create timeline event tag' do
    before do
      project.add_developer(user)
    end

    it 'raises error' do
      post_graphql_mutation(mutation, current_user: user)

      expect(mutation_response).to be_nil
      expect_graphql_errors_to_include(Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR)
    end
  end
end