diff options
Diffstat (limited to 'spec/features/groups/issues_spec.rb')
| -rw-r--r-- | spec/features/groups/issues_spec.rb | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/spec/features/groups/issues_spec.rb b/spec/features/groups/issues_spec.rb index 176f4a668ff..0cb24ef856b 100644 --- a/spec/features/groups/issues_spec.rb +++ b/spec/features/groups/issues_spec.rb @@ -1,7 +1,10 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'Group issues page' do include FilteredSearchHelpers + include DragTo let(:group) { create(:group) } let(:project) { create(:project, :public, group: group)} @@ -49,7 +52,7 @@ describe 'Group issues page' do end end - context 'issues list', :nested_groups do + context 'issues list' do let(:subgroup) { create(:group, parent: group) } let(:subgroup_project) { create(:project, :public, group: subgroup)} let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group ).user } @@ -99,4 +102,81 @@ describe 'Group issues page' do end end end + + context 'manual ordering' do + let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group ).user } + + let!(:issue1) { create(:issue, project: project, title: 'Issue #1', relative_position: 1) } + let!(:issue2) { create(:issue, project: project, title: 'Issue #2', relative_position: 2) } + let!(:issue3) { create(:issue, project: project, title: 'Issue #3', relative_position: 3) } + + before do + sign_in(user_in_group) + end + + it 'displays all issues' do + visit issues_group_path(group, sort: 'relative_position') + + page.within('.issues-list') do + expect(page).to have_selector('li.issue', count: 3) + end + end + + it 'has manual-ordering css applied' do + visit issues_group_path(group, sort: 'relative_position') + + expect(page).to have_selector('.manual-ordering') + end + + it 'each issue item has a user-can-drag css applied' do + visit issues_group_path(group, sort: 'relative_position') + + page.within('.manual-ordering') do + expect(page).to have_selector('.issue.user-can-drag', count: 3) + end + end + + it 'issues should be draggable and persist order', :js do + visit issues_group_path(group, sort: 'relative_position') + + drag_to(selector: '.manual-ordering', + from_index: 0, + to_index: 2) + + wait_for_requests + + check_issue_order + + visit issues_group_path(group, sort: 'relative_position') + + check_issue_order + end + + it 'issues should not be draggable when user is not logged in', :js do + sign_out(user_in_group) + + visit issues_group_path(group, sort: 'relative_position') + + drag_to(selector: '.manual-ordering', + from_index: 0, + to_index: 2) + + wait_for_requests + + # Issue order should remain the same + page.within('.manual-ordering') do + expect(find('.issue:nth-child(1) .title')).to have_content('Issue #1') + expect(find('.issue:nth-child(2) .title')).to have_content('Issue #2') + expect(find('.issue:nth-child(3) .title')).to have_content('Issue #3') + end + end + + def check_issue_order + page.within('.manual-ordering') do + expect(find('.issue:nth-child(1) .title')).to have_content('Issue #2') + expect(find('.issue:nth-child(2) .title')).to have_content('Issue #3') + expect(find('.issue:nth-child(3) .title')).to have_content('Issue #1') + end + end + end end |
