diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-10 21:09:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-10 21:09:54 +0300 |
commit | 350fd8b878fe930b83c52ccae82f861cc499776a (patch) | |
tree | aa01a35b06921103ba9967920165419accb9f72d /spec/requests | |
parent | 70732753863e569f95ed954ca3c41421292f912b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/graphql/milestone_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/requests/api/graphql/milestone_spec.rb b/spec/requests/api/graphql/milestone_spec.rb new file mode 100644 index 00000000000..59de116fa2b --- /dev/null +++ b/spec/requests/api/graphql/milestone_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Querying a Milestone' do + include GraphqlHelpers + + let_it_be(:current_user) { create(:user) } + let_it_be(:project) { create(:project) } + let_it_be(:milestone) { create(:milestone, project: project) } + + let(:query) do + graphql_query_for('milestone', { id: milestone.to_global_id.to_s }, 'title') + end + + subject { graphql_data['milestone'] } + + before do + post_graphql(query, current_user: current_user) + end + + context 'when the user has access to the milestone' do + before_all do + project.add_guest(current_user) + end + + it_behaves_like 'a working graphql query' + + it { is_expected.to include('title' => milestone.name) } + end + + context 'when the user does not have access to the milestone' do + it_behaves_like 'a working graphql query' + + it { is_expected.to be_nil } + end + + context 'when ID argument is missing' do + let(:query) do + graphql_query_for('milestone', {}, 'title') + end + + it 'raises an exception' do + expect(graphql_errors).to include(a_hash_including('message' => "Field 'milestone' is missing required arguments: id")) + end + end +end |