diff options
Diffstat (limited to 'spec/requests/api/graphql/query_spec.rb')
-rw-r--r-- | spec/requests/api/graphql/query_spec.rb | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/spec/requests/api/graphql/query_spec.rb b/spec/requests/api/graphql/query_spec.rb index d93077b1c70..0602cfec149 100644 --- a/spec/requests/api/graphql/query_spec.rb +++ b/spec/requests/api/graphql/query_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Query', feature_category: :shared do include GraphqlHelpers - let_it_be(:project) { create(:project) } + let_it_be(:project) { create(:project, public_builds: false) } let_it_be(:issue) { create(:issue, project: project) } let_it_be(:developer) { create(:user) } @@ -116,4 +116,36 @@ RSpec.describe 'Query', feature_category: :shared do end end end + + describe '.ciPipelineStage' do + let_it_be(:ci_stage) { create(:ci_stage, name: 'graphql test stage', project: project) } + + let(:query) do + <<~GRAPHQL + { + ciPipelineStage(id: "#{ci_stage.to_global_id}") { + name + } + } + GRAPHQL + end + + context 'when the current user has access to the stage' do + it 'fetches the stage for the given ID' do + project.add_developer(developer) + + post_graphql(query, current_user: developer) + + expect(graphql_data.dig('ciPipelineStage', 'name')).to eq('graphql test stage') + end + end + + context 'when the current user does not have access to the stage' do + it 'returns nil' do + post_graphql(query, current_user: developer) + + expect(graphql_data['ciPipelineStage']).to be_nil + end + end + end end |