diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-24 21:09:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-24 21:09:05 +0300 |
commit | c2367afbf57ebc65d5b78a743b5d6a91f0aece9f (patch) | |
tree | 165c2c54bf72ab3a3a9417d97f63ece5c9eba9f5 /spec/support | |
parent | 51a9512965d86e3094968fa514e4ae8a96d38cf3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
2 files changed, 34 insertions, 0 deletions
diff --git a/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb b/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb index e744c3d0abb..ca77c68c130 100644 --- a/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb +++ b/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb @@ -5,6 +5,8 @@ RSpec.shared_context 'group and project boards query context' do let(:current_user) { user } let(:params) { '' } let(:board_parent_type) { board_parent.class.to_s.downcase } + let(:boards_data) { graphql_data[board_parent_type]['boards']['edges'] } + let(:board_data) { graphql_data[board_parent_type]['board'] } let(:start_cursor) { graphql_data[board_parent_type]['boards']['pageInfo']['startCursor'] } let(:end_cursor) { graphql_data[board_parent_type]['boards']['pageInfo']['endCursor'] } @@ -28,6 +30,18 @@ RSpec.shared_context 'group and project boards query context' do ) end + def query_single_board(board_params = params) + graphql_query_for( + board_parent_type, + { 'fullPath' => board_parent.full_path }, + <<~BOARD + board(#{board_params}) { + #{all_graphql_fields_for('board'.classify)} + } + BOARD + ) + end + def grab_names(data = boards_data) data.map do |board| board.dig('node', 'name') diff --git a/spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb b/spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb index 6044fefd2f7..90ac60a6fe7 100644 --- a/spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb @@ -89,4 +89,24 @@ RSpec.shared_examples 'group and project boards query' do end end end + + context 'when querying for a single board' do + before do + board_parent.add_reporter(current_user) + end + + it_behaves_like 'a working graphql query' do + before do + post_graphql(query_single_board, current_user: current_user) + end + end + + it 'finds the correct board' do + board = create(:board, resource_parent: board_parent, name: 'A') + + post_graphql(query_single_board("id: \"#{global_id_of(board)}\""), current_user: current_user) + + expect(board_data['name']).to eq board.name + end + end end |