diff options
author | Heinrich Lee Yu <hleeyu@gmail.com> | 2018-10-27 11:18:31 +0800 |
---|---|---|
committer | Heinrich Lee Yu <hleeyu@gmail.com> | 2018-11-01 07:45:36 +0800 |
commit | 385524c3ea7bde5cac889776b08a7287e241387f (patch) | |
tree | 45dbd633119efcaaff3fc76e8865d1ef6df35ca4 /spec | |
parent | 4f53ab13c6b1f7327b7df3e584ef3786bf8f5641 (diff) | |
download | gitlab-ce-385524c3ea7bde5cac889776b08a7287e241387f.tar.gz |
Add tests
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/issues/filtered_search/dropdown_emoji_spec.rb | 16 | ||||
-rw-r--r-- | spec/finders/issues_finder_spec.rb | 16 | ||||
-rw-r--r-- | spec/requests/api/issues_spec.rb | 18 |
3 files changed, 46 insertions, 4 deletions
diff --git a/spec/features/issues/filtered_search/dropdown_emoji_spec.rb b/spec/features/issues/filtered_search/dropdown_emoji_spec.rb index be229e8aa7d..f5400e00156 100644 --- a/spec/features/issues/filtered_search/dropdown_emoji_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_emoji_spec.rb @@ -121,6 +121,22 @@ describe 'Dropdown emoji', :js do send_keys_to_filtered_search(':') end + it 'selects `None`' do + find('#js-dropdown-assignee .filter-dropdown-item', text: 'None').click + + expect(page).to have_css(js_dropdown_emoji, visible: false) + expect_tokens([emoji_token('none')]) + expect_filtered_search_input_empty + end + + it 'selects `Any`' do + find('#js-dropdown-assignee .filter-dropdown-item', text: 'Any').click + + expect(page).to have_css(js_dropdown_emoji, visible: false) + expect_tokens([emoji_token('any')]) + expect_filtered_search_input_empty + end + it 'fills in the my-reaction name' do click_emoji('thumbsup') diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index 2f164ffa8b0..490cfdfe116 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -360,6 +360,22 @@ describe IssuesFinder do end context 'filtering by reaction name' do + context 'user searches by no reaction' do + let(:params) { { my_reaction_emoji: 'None' } } + + it 'returns issues that the user did not react to' do + expect(issues).to contain_exactly(issue2, issue4) + end + end + + context 'user searches by any reaction' do + let(:params) { { my_reaction_emoji: 'Any' } } + + it 'returns issues that the user reacted to' do + expect(issues).to contain_exactly(issue1, issue3) + end + end + context 'user searches by "thumbsup" reaction' do let(:params) { { my_reaction_emoji: 'thumbsup' } } diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 9cda39a569b..ff32290db07 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -196,14 +196,24 @@ describe API::Issues do expect_paginated_array_response(size: 3) end - it 'returns issues reacted by the authenticated user by the given emoji' do + it 'returns issues reacted by the authenticated user' do issue2 = create(:issue, project: project, author: user, assignees: [user]) award_emoji = create(:award_emoji, awardable: issue2, user: user2, name: 'star') - get api('/issues', user2), my_reaction_emoji: award_emoji.name, scope: 'all' + create(:award_emoji, awardable: issue, user: user2, name: 'thumbsup') - expect_paginated_array_response(size: 1) - expect(first_issue['id']).to eq(issue2.id) + get api('/issues', user2), my_reaction_emoji: 'Any', scope: 'all' + + expect_paginated_array_response(size: 2) + end + + it 'returns issues not reacted by the authenticated user' do + issue2 = create(:issue, project: project, author: user, assignees: [user]) + create(:award_emoji, awardable: issue2, user: user2, name: 'star') + + get api('/issues', user2), my_reaction_emoji: 'None', scope: 'all' + + expect_paginated_array_response(size: 2) end it 'returns issues matching given search string for title' do |