diff options
Diffstat (limited to 'spec/graphql/resolvers/board_list_issues_resolver_spec.rb')
-rw-r--r-- | spec/graphql/resolvers/board_list_issues_resolver_spec.rb | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/spec/graphql/resolvers/board_list_issues_resolver_spec.rb b/spec/graphql/resolvers/board_list_issues_resolver_spec.rb index e23a37b3d69..4ccf194522f 100644 --- a/spec/graphql/resolvers/board_list_issues_resolver_spec.rb +++ b/spec/graphql/resolvers/board_list_issues_resolver_spec.rb @@ -11,41 +11,59 @@ RSpec.describe Resolvers::BoardListIssuesResolver do 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) } + let!(:issue1) { create(:issue, project: project, labels: [label], relative_position: 10) } + let!(:issue2) { create(:issue, project: project, labels: [label, label2], relative_position: 12) } + let!(:issue3) { create(:issue, project: project, labels: [label, label3], relative_position: 10) } 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 + + it 'finds only issues matching filters' do + result = resolve_board_list_issues(args: { filters: { label_name: label.title, not: { label_name: label2.title } } }).items + + expect(result).to match_array([issue1, issue3]) + end + + it 'finds only issues matching search param' do + result = resolve_board_list_issues(args: { filters: { search: issue1.title } }).items + + expect(result).to match_array([issue1]) + end end end describe '#resolve' do context 'when project boards' do + let_it_be(:label) { create(:label, project: user_project) } + let_it_be(:label2) { create(:label, project: user_project) } + let_it_be(:label3) { create(:label, project: user_project) } + let_it_be(:board) { create(:board, resource_parent: user_project) } + let_it_be(:list) { create(:list, board: board, label: label) } + 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_it_be(:label) { create(:group_label, group: group) } + let_it_be(:label2) { create(:group_label, group: group) } + let_it_be(:label3) { create(:group_label, group: group) } + let_it_be(:board) { create(:board, resource_parent: group) } + let_it_be(:list) { create(:list, board: board, label: label) } + 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' |