diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/graphql/resolvers/board_list_issues_resolver_spec.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/graphql/resolvers/board_list_issues_resolver_spec.rb')
-rw-r--r-- | spec/graphql/resolvers/board_list_issues_resolver_spec.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/graphql/resolvers/board_list_issues_resolver_spec.rb b/spec/graphql/resolvers/board_list_issues_resolver_spec.rb new file mode 100644 index 00000000000..e23a37b3d69 --- /dev/null +++ b/spec/graphql/resolvers/board_list_issues_resolver_spec.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Resolvers::BoardListIssuesResolver do + include GraphqlHelpers + + let_it_be(:user) { create(:user) } + let_it_be(:unauth_user) { create(:user) } + let_it_be(:user_project) { create(:project, creator_id: user.id, namespace: user.namespace ) } + let_it_be(:group) { create(:group, :private) } + + shared_examples_for 'group and project board list issues resolver' do + let!(:board) { create(:board, resource_parent: board_parent) } + + before do + board_parent.add_developer(user) + end + + # auth is handled by the parent object + context 'when authorized' do + let!(:list) { create(:list, board: board, label: label) } + + it 'returns the issues in the correct order' do + issue1 = create(:issue, project: project, labels: [label], relative_position: 10) + issue2 = create(:issue, project: project, labels: [label], relative_position: 12) + issue3 = create(:issue, project: project, labels: [label], relative_position: 10) + + # by relative_position and then ID + issues = resolve_board_list_issues.items + + expect(issues.map(&:id)).to eq [issue3.id, issue1.id, issue2.id] + end + end + end + + describe '#resolve' do + context 'when project boards' do + let(:board_parent) { user_project } + let!(:label) { create(:label, project: project, name: 'project label') } + let(:project) { user_project } + + it_behaves_like 'group and project board list issues resolver' + end + + context 'when group boards' do + let(:board_parent) { group } + let!(:label) { create(:group_label, group: group, name: 'group label') } + let!(:project) { create(:project, :private, group: group) } + + it_behaves_like 'group and project board list issues resolver' + end + end + + def resolve_board_list_issues(args: {}, current_user: user) + resolve(described_class, obj: list, args: args, ctx: { current_user: current_user }) + end +end |