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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
require 'rails_helper'
describe 'Group milestones' do
let(:group) { create(:group) }
let!(:project) { create(:project_empty_repo, group: group) }
let(:user) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
around do |example|
Timecop.freeze { example.run }
end
before do
sign_in(user)
end
context 'create a milestone', :js do
before do
visit new_group_milestone_path(group)
end
it 'renders description preview' do
description = find('.note-textarea')
description.native.send_keys('')
click_link('Preview')
preview = find('.js-md-preview')
expect(preview).to have_content('Nothing to preview.')
click_link('Write')
description.native.send_keys(':+1: Nice')
click_link('Preview')
expect(preview).to have_css('gl-emoji')
expect(find('#milestone_description', visible: false)).not_to be_visible
end
it 'creates milestone with start date' do
fill_in 'Title', with: 'testing'
find('#milestone_start_date').click
page.within(find('.pika-single')) do
click_button '1'
end
click_button 'Create milestone'
expect(find('.start_date')).to have_content(Date.today.at_beginning_of_month.strftime('%b %-d, %Y'))
end
it 'description input does not support autocomplete' do
description = find('.note-textarea')
description.native.send_keys('!')
expect(page).not_to have_selector('.atwho-view')
end
end
context 'milestones list' do
context 'when no milestones' do
it 'renders no milestones text' do
visit group_milestones_path(group)
expect(page).to have_content('No milestones to show')
end
end
context 'when milestones exists' do
let!(:other_project) { create(:project_empty_repo, group: group) }
let!(:active_project_milestone1) do
create(
:milestone,
project: project,
state: 'active',
title: 'v1.0',
due_date: '2114-08-20',
description: 'Lorem Ipsum is simply dummy text'
)
end
let!(:active_project_milestone2) { create(:milestone, project: other_project, state: 'active', title: 'v1.0') }
let!(:closed_project_milestone1) { create(:milestone, project: project, state: 'closed', title: 'v2.0') }
let!(:closed_project_milestone2) { create(:milestone, project: other_project, state: 'closed', title: 'v2.0') }
let!(:active_group_milestone) { create(:milestone, group: group, state: 'active', title: 'GL-113') }
let!(:closed_group_milestone) { create(:milestone, group: group, state: 'closed') }
let!(:issue) do
create :issue, project: project, assignees: [user], author: user, milestone: active_project_milestone1
end
before do
visit group_milestones_path(group)
end
it 'counts milestones correctly' do
expect(find('.top-area .active .badge').text).to eq("2")
expect(find('.top-area .closed .badge').text).to eq("2")
expect(find('.top-area .all .badge').text).to eq("4")
end
it 'lists legacy group milestones and group milestones' do
legacy_milestone = GroupMilestone.build_collection(group, group.projects, { state: 'active' }).first
expect(page).to have_selector("#milestone_#{active_group_milestone.id}", count: 1)
expect(page).to have_selector("#milestone_#{legacy_milestone.milestones.first.id}", count: 1)
end
it 'shows milestone detail and supports its edit' do
page.within(".milestones #milestone_#{active_group_milestone.id}") do
click_link(active_group_milestone.title)
end
page.within('.detail-page-header') do
click_link('Edit')
end
expect(page).to have_selector('.milestone-form')
end
it 'renders milestones' do
expect(page).to have_content('v1.0')
expect(page).to have_content('GL-113')
expect(page).to have_link(
'1 Issue',
href: issues_group_path(group, milestone_title: 'v1.0')
)
expect(page).to have_link(
'0 Merge Requests',
href: merge_requests_group_path(group, milestone_title: 'v1.0')
)
end
it 'renders group milestone details' do
click_link 'v1.0'
expect(page).to have_content('expires on Aug 20, 2114')
expect(page).to have_content('v1.0')
expect(page).to have_content('Issues 1 Open: 1 Closed: 0')
expect(page).to have_link(issue.title, href: project_issue_path(issue.project, issue))
end
describe 'labels' do
before do
create(:label, project: project, title: 'bug') do |label|
issue.labels << label
end
create(:label, project: project, title: 'feature') do |label|
issue.labels << label
end
end
it 'renders labels' do
click_link 'v1.0'
page.within('#tab-issues') do
expect(page).to have_content 'bug'
expect(page).to have_content 'feature'
end
end
it 'renders labels list', :js do
click_link 'v1.0'
page.within('.content .nav-links') do
page.find(:xpath, "//a[@href='#tab-labels']").click
end
page.within('#tab-labels') do
expect(page).to have_content 'bug'
expect(page).to have_content 'feature'
end
end
end
end
end
end
|