1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
require 'rails_helper'
describe 'Milestone draggable', feature: true, js: true do
include WaitForAjax
include DragTo
let(:milestone) { create(:milestone, project: project, title: 8.14) }
let(:project) { create(:empty_project, :public) }
let(:user) { create(:user) }
context 'issues' do
let(:issue) { page.find_by_id('issues-list-unassigned').find('li') }
let(:issue_target) { page.find_by_id('issues-list-ongoing') }
it 'does not allow guest to drag issue' do
create_and_drag_issue
expect(issue_target).not_to have_selector('.issuable-row')
end
it 'does not allow authorized user to drag issue' do
login_as(user)
create_and_drag_issue
expect(issue_target).not_to have_selector('.issuable-row')
end
it 'allows author to drag issue' do
login_as(user)
create_and_drag_issue(author: user)
expect(issue_target).to have_selector('.issuable-row')
end
it 'allows admin to drag issue' do
login_as(:admin)
create_and_drag_issue
expect(issue_target).to have_selector('.issuable-row')
end
end
context 'merge requests' do
let(:merge_request) { page.find_by_id('merge_requests-list-unassigned').find('li') }
let(:merge_request_target) { page.find_by_id('merge_requests-list-ongoing') }
it 'does not allow guest to drag merge request' do
create_and_drag_merge_request
expect(merge_request_target).not_to have_selector('.issuable-row')
end
it 'does not allow authorized user to drag merge request' do
login_as(user)
create_and_drag_merge_request
expect(merge_request_target).not_to have_selector('.issuable-row')
end
it 'allows author to drag merge request' do
login_as(user)
create_and_drag_merge_request(author: user)
expect(merge_request_target).to have_selector('.issuable-row')
end
it 'allows admin to drag merge request' do
login_as(:admin)
create_and_drag_merge_request
expect(merge_request_target).to have_selector('.issuable-row')
end
end
def create_and_drag_issue(params = {})
create(:issue, params.merge(title: 'Foo', project: project, milestone: milestone))
visit namespace_project_milestone_path(project.namespace, project, milestone)
scroll_into_view('.milestone-content')
drag_to(selector: '.issues-sortable-list', list_to_index: 1)
wait_for_ajax
end
def create_and_drag_merge_request(params = {})
create(:merge_request, params.merge(title: 'Foo', source_project: project, target_project: project, milestone: milestone))
visit namespace_project_milestone_path(project.namespace, project, milestone)
page.find("a[href='#tab-merge-requests']").click
scroll_into_view('.milestone-content')
drag_to(selector: '.merge_requests-sortable-list', list_to_index: 1)
wait_for_ajax
end
def scroll_into_view(selector)
page.evaluate_script("document.querySelector('#{selector}').scrollIntoView();")
end
end
|