|
@@
-1,267
+1,278
|
|
1
|
# Redmine - project management software
|
|
1
|
# Redmine - project management software
|
|
2
|
# Copyright (C) 2006-2015 Jean-Philippe Lang
|
|
2
|
# Copyright (C) 2006-2015 Jean-Philippe Lang
|
|
3
|
#
|
|
3
|
#
|
|
4
|
# This program is free software; you can redistribute it and/or
|
|
4
|
# This program is free software; you can redistribute it and/or
|
|
5
|
# modify it under the terms of the GNU General Public License
|
|
5
|
# modify it under the terms of the GNU General Public License
|
|
6
|
# as published by the Free Software Foundation; either version 2
|
|
6
|
# as published by the Free Software Foundation; either version 2
|
|
7
|
# of the License, or (at your option) any later version.
|
|
7
|
# of the License, or (at your option) any later version.
|
|
8
|
#
|
|
8
|
#
|
|
9
|
# This program is distributed in the hope that it will be useful,
|
|
9
|
# This program is distributed in the hope that it will be useful,
|
|
10
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
# GNU General Public License for more details.
|
|
12
|
# GNU General Public License for more details.
|
|
13
|
#
|
|
13
|
#
|
|
14
|
# You should have received a copy of the GNU General Public License
|
|
14
|
# You should have received a copy of the GNU General Public License
|
|
15
|
# along with this program; if not, write to the Free Software
|
|
15
|
# along with this program; if not, write to the Free Software
|
|
16
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
16
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
17
|
|
|
17
|
|
|
18
|
require File.expand_path('../base', __FILE__)
|
|
18
|
require File.expand_path('../base', __FILE__)
|
|
19
|
|
|
19
|
|
|
20
|
class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base
|
|
20
|
class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base
|
|
21
|
fixtures :projects, :users, :roles, :members, :member_roles,
|
|
21
|
fixtures :projects, :users, :roles, :members, :member_roles,
|
|
22
|
:trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
|
|
22
|
:trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
|
|
23
|
:enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
|
|
23
|
:enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
|
|
24
|
:watchers
|
|
24
|
:watchers
|
|
25
|
|
|
25
|
|
|
26
|
def test_create_issue
|
|
26
|
def test_create_issue
|
|
27
|
log_user('jsmith', 'jsmith')
|
|
27
|
log_user('jsmith', 'jsmith')
|
|
28
|
visit '/projects/ecookbook/issues/new'
|
|
28
|
visit '/projects/ecookbook/issues/new'
|
|
29
|
within('form#issue-form') do
|
|
29
|
within('form#issue-form') do
|
|
30
|
select 'Bug', :from => 'Tracker'
|
|
30
|
select 'Bug', :from => 'Tracker'
|
|
31
|
select 'Low', :from => 'Priority'
|
|
31
|
select 'Low', :from => 'Priority'
|
|
32
|
fill_in 'Subject', :with => 'new test issue'
|
|
32
|
fill_in 'Subject', :with => 'new test issue'
|
|
33
|
fill_in 'Description', :with => 'new issue'
|
|
33
|
fill_in 'Description', :with => 'new issue'
|
|
34
|
select '0 %', :from => 'Done'
|
|
34
|
select '0 %', :from => 'Done'
|
|
35
|
fill_in 'Due date', :with => ''
|
|
35
|
fill_in 'Due date', :with => ''
|
|
36
|
fill_in 'Searchable field', :with => 'Value for field 2'
|
|
36
|
fill_in 'Searchable field', :with => 'Value for field 2'
|
|
37
|
# click_button 'Create' would match both 'Create' and 'Create and continue' buttons
|
|
37
|
# click_button 'Create' would match both 'Create' and 'Create and continue' buttons
|
|
38
|
find('input[name=commit]').click
|
|
38
|
find('input[name=commit]').click
|
|
39
|
end
|
|
39
|
end
|
|
40
|
|
|
40
|
|
|
41
|
# find created issue
|
|
41
|
# find created issue
|
|
42
|
issue = Issue.find_by_subject("new test issue")
|
|
42
|
issue = Issue.find_by_subject("new test issue")
|
|
43
|
assert_kind_of Issue, issue
|
|
43
|
assert_kind_of Issue, issue
|
|
44
|
|
|
44
|
|
|
45
|
# check redirection
|
|
45
|
# check redirection
|
|
46
|
find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created."
|
|
46
|
find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created."
|
|
47
|
assert_equal issue_path(:id => issue), current_path
|
|
47
|
assert_equal issue_path(:id => issue), current_path
|
|
48
|
|
|
48
|
|
|
49
|
# check issue attributes
|
|
49
|
# check issue attributes
|
|
50
|
assert_equal 'jsmith', issue.author.login
|
|
50
|
assert_equal 'jsmith', issue.author.login
|
|
51
|
assert_equal 1, issue.project.id
|
|
51
|
assert_equal 1, issue.project.id
|
|
52
|
assert_equal IssueStatus.find_by_name('New'), issue.status
|
|
52
|
assert_equal IssueStatus.find_by_name('New'), issue.status
|
|
53
|
assert_equal Tracker.find_by_name('Bug'), issue.tracker
|
|
53
|
assert_equal Tracker.find_by_name('Bug'), issue.tracker
|
|
54
|
assert_equal IssuePriority.find_by_name('Low'), issue.priority
|
|
54
|
assert_equal IssuePriority.find_by_name('Low'), issue.priority
|
|
55
|
assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field'))
|
|
55
|
assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field'))
|
|
56
|
end
|
|
56
|
end
|
|
57
|
|
|
57
|
|
|
58
|
def test_create_issue_with_form_update
|
|
58
|
def test_create_issue_with_form_update
|
|
59
|
field1 = IssueCustomField.create!(
|
|
59
|
field1 = IssueCustomField.create!(
|
|
60
|
:field_format => 'string',
|
|
60
|
:field_format => 'string',
|
|
61
|
:name => 'Field1',
|
|
61
|
:name => 'Field1',
|
|
62
|
:is_for_all => true,
|
|
62
|
:is_for_all => true,
|
|
63
|
:trackers => Tracker.where(:id => [1, 2])
|
|
63
|
:trackers => Tracker.where(:id => [1, 2])
|
|
64
|
)
|
|
64
|
)
|
|
65
|
field2 = IssueCustomField.create!(
|
|
65
|
field2 = IssueCustomField.create!(
|
|
66
|
:field_format => 'string',
|
|
66
|
:field_format => 'string',
|
|
67
|
:name => 'Field2',
|
|
67
|
:name => 'Field2',
|
|
68
|
:is_for_all => true,
|
|
68
|
:is_for_all => true,
|
|
69
|
:trackers => Tracker.where(:id => 2)
|
|
69
|
:trackers => Tracker.where(:id => 2)
|
|
70
|
)
|
|
70
|
)
|
|
71
|
|
|
71
|
|
|
72
|
Role.non_member.add_permission! :add_issues
|
|
72
|
Role.non_member.add_permission! :add_issues
|
|
73
|
Role.non_member.remove_permission! :edit_issues, :add_issue_notes
|
|
73
|
Role.non_member.remove_permission! :edit_issues, :add_issue_notes
|
|
74
|
|
|
74
|
|
|
75
|
log_user('someone', 'foo')
|
|
75
|
log_user('someone', 'foo')
|
|
76
|
visit '/projects/ecookbook/issues/new'
|
|
76
|
visit '/projects/ecookbook/issues/new'
|
|
77
|
assert page.has_no_content?(field2.name)
|
|
77
|
assert page.has_no_content?(field2.name)
|
|
78
|
assert page.has_content?(field1.name)
|
|
78
|
assert page.has_content?(field1.name)
|
|
79
|
|
|
79
|
|
|
80
|
fill_in 'Subject', :with => 'New test issue'
|
|
80
|
fill_in 'Subject', :with => 'New test issue'
|
|
81
|
fill_in 'Description', :with => 'New test issue description'
|
|
81
|
fill_in 'Description', :with => 'New test issue description'
|
|
82
|
fill_in field1.name, :with => 'CF1 value'
|
|
82
|
fill_in field1.name, :with => 'CF1 value'
|
|
83
|
select 'Low', :from => 'Priority'
|
|
83
|
select 'Low', :from => 'Priority'
|
|
84
|
|
|
84
|
|
|
85
|
# field2 should show up when changing tracker
|
|
85
|
# field2 should show up when changing tracker
|
|
86
|
select 'Feature request', :from => 'Tracker'
|
|
86
|
select 'Feature request', :from => 'Tracker'
|
|
87
|
assert page.has_content?(field2.name)
|
|
87
|
assert page.has_content?(field2.name)
|
|
88
|
assert page.has_content?(field1.name)
|
|
88
|
assert page.has_content?(field1.name)
|
|
89
|
|
|
89
|
|
|
90
|
fill_in field2.name, :with => 'CF2 value'
|
|
90
|
fill_in field2.name, :with => 'CF2 value'
|
|
91
|
assert_difference 'Issue.count' do
|
|
91
|
assert_difference 'Issue.count' do
|
|
92
|
page.first(:button, 'Create').click
|
|
92
|
page.first(:button, 'Create').click
|
|
93
|
end
|
|
93
|
end
|
|
94
|
|
|
94
|
|
|
95
|
issue = Issue.order('id desc').first
|
|
95
|
issue = Issue.order('id desc').first
|
|
96
|
assert_equal 'New test issue', issue.subject
|
|
96
|
assert_equal 'New test issue', issue.subject
|
|
97
|
assert_equal 'New test issue description', issue.description
|
|
97
|
assert_equal 'New test issue description', issue.description
|
|
98
|
assert_equal 'Low', issue.priority.name
|
|
98
|
assert_equal 'Low', issue.priority.name
|
|
99
|
assert_equal 'CF1 value', issue.custom_field_value(field1)
|
|
99
|
assert_equal 'CF1 value', issue.custom_field_value(field1)
|
|
100
|
assert_equal 'CF2 value', issue.custom_field_value(field2)
|
|
100
|
assert_equal 'CF2 value', issue.custom_field_value(field2)
|
|
101
|
end
|
|
101
|
end
|
|
102
|
|
|
102
|
|
|
103
|
def test_create_issue_with_watchers
|
|
103
|
def test_create_issue_with_watchers
|
|
104
|
user = User.generate!(:firstname => 'Some', :lastname => 'Watcher')
|
|
104
|
user = User.generate!(:firstname => 'Some', :lastname => 'Watcher')
|
|
105
|
assert_equal 'Some Watcher', user.name
|
|
105
|
assert_equal 'Some Watcher', user.name
|
|
106
|
log_user('jsmith', 'jsmith')
|
|
106
|
log_user('jsmith', 'jsmith')
|
|
107
|
visit '/projects/ecookbook/issues/new'
|
|
107
|
visit '/projects/ecookbook/issues/new'
|
|
108
|
fill_in 'Subject', :with => 'Issue with watchers'
|
|
108
|
fill_in 'Subject', :with => 'Issue with watchers'
|
|
109
|
# Add a project member as watcher
|
|
109
|
# Add a project member as watcher
|
|
110
|
check 'Dave Lopper'
|
|
110
|
check 'Dave Lopper'
|
|
111
|
# Search for another user
|
|
111
|
# Search for another user
|
|
112
|
assert page.has_no_css?('form#new-watcher-form')
|
|
112
|
assert page.has_no_css?('form#new-watcher-form')
|
|
113
|
assert page.has_no_content?('Some Watcher')
|
|
113
|
assert page.has_no_content?('Some Watcher')
|
|
114
|
click_link 'Search for watchers to add'
|
|
114
|
click_link 'Search for watchers to add'
|
|
115
|
within('form#new-watcher-form') do
|
|
115
|
within('form#new-watcher-form') do
|
|
116
|
fill_in 'user_search', :with => 'watch'
|
|
116
|
fill_in 'user_search', :with => 'watch'
|
|
117
|
assert page.has_content?('Some Watcher')
|
|
117
|
assert page.has_content?('Some Watcher')
|
|
118
|
check 'Some Watcher'
|
|
118
|
check 'Some Watcher'
|
|
119
|
click_button 'Add'
|
|
119
|
click_button 'Add'
|
|
120
|
end
|
|
120
|
end
|
|
121
|
assert page.has_css?('form#issue-form')
|
|
121
|
assert page.has_css?('form#issue-form')
|
|
122
|
assert page.has_css?('p#watchers_form')
|
|
122
|
assert page.has_css?('p#watchers_form')
|
|
123
|
using_wait_time(30) do
|
|
123
|
using_wait_time(30) do
|
|
124
|
within('span#watchers_inputs') do
|
|
124
|
within('span#watchers_inputs') do
|
|
125
|
within("label#issue_watcher_user_ids_#{user.id}") do
|
|
125
|
within("label#issue_watcher_user_ids_#{user.id}") do
|
|
126
|
assert has_content?('Some Watcher'), "No watcher content"
|
|
126
|
assert has_content?('Some Watcher'), "No watcher content"
|
|
127
|
end
|
|
127
|
end
|
|
128
|
end
|
|
128
|
end
|
|
129
|
end
|
|
129
|
end
|
|
130
|
assert_difference 'Issue.count' do
|
|
130
|
assert_difference 'Issue.count' do
|
|
131
|
find('input[name=commit]').click
|
|
131
|
find('input[name=commit]').click
|
|
132
|
end
|
|
132
|
end
|
|
133
|
|
|
133
|
|
|
134
|
issue = Issue.order('id desc').first
|
|
134
|
issue = Issue.order('id desc').first
|
|
135
|
assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort
|
|
135
|
assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort
|
|
136
|
end
|
|
136
|
end
|
|
137
|
|
|
137
|
|
|
138
|
def test_create_issue_start_due_date
|
|
138
|
def test_create_issue_start_due_date
|
|
139
|
with_settings :default_issue_start_date_to_creation_date => 0 do
|
|
139
|
with_settings :default_issue_start_date_to_creation_date => 0 do
|
|
140
|
log_user('jsmith', 'jsmith')
|
|
140
|
log_user('jsmith', 'jsmith')
|
|
141
|
visit '/projects/ecookbook/issues/new'
|
|
141
|
visit '/projects/ecookbook/issues/new'
|
|
142
|
assert_equal "", page.find('input#issue_start_date').value
|
|
142
|
assert_equal "", page.find('input#issue_start_date').value
|
|
143
|
assert_equal "", page.find('input#issue_due_date').value
|
|
143
|
assert_equal "", page.find('input#issue_due_date').value
|
|
144
|
page.first('p#start_date_area img').click
|
|
144
|
page.first('p#start_date_area img').click
|
|
145
|
page.first("td.ui-datepicker-days-cell-over a").click
|
|
145
|
page.first("td.ui-datepicker-days-cell-over a").click
|
|
146
|
assert_equal Date.today.to_s, page.find('input#issue_start_date').value
|
|
146
|
assert_equal Date.today.to_s, page.find('input#issue_start_date').value
|
|
147
|
page.first('p#due_date_area img').click
|
|
147
|
page.first('p#due_date_area img').click
|
|
148
|
page.first("td.ui-datepicker-days-cell-over a").click
|
|
148
|
page.first("td.ui-datepicker-days-cell-over a").click
|
|
149
|
assert_equal Date.today.to_s, page.find('input#issue_due_date').value
|
|
149
|
assert_equal Date.today.to_s, page.find('input#issue_due_date').value
|
|
150
|
end
|
|
150
|
end
|
|
151
|
end
|
|
151
|
end
|
|
152
|
|
|
152
|
|
|
153
|
def test_create_issue_start_due_date_default
|
|
153
|
def test_create_issue_start_due_date_default
|
|
154
|
log_user('jsmith', 'jsmith')
|
|
154
|
log_user('jsmith', 'jsmith')
|
|
155
|
visit '/projects/ecookbook/issues/new'
|
|
155
|
visit '/projects/ecookbook/issues/new'
|
|
156
|
fill_in 'Start date', :with => '2012-04-01'
|
|
156
|
fill_in 'Start date', :with => '2012-04-01'
|
|
157
|
fill_in 'Due date', :with => ''
|
|
157
|
fill_in 'Due date', :with => ''
|
|
158
|
page.first('p#due_date_area img').click
|
|
158
|
page.first('p#due_date_area img').click
|
|
159
|
page.first("td.ui-datepicker-days-cell-over a").click
|
|
159
|
page.first("td.ui-datepicker-days-cell-over a").click
|
|
160
|
assert_equal '2012-04-01', page.find('input#issue_due_date').value
|
|
160
|
assert_equal '2012-04-01', page.find('input#issue_due_date').value
|
|
161
|
|
|
161
|
|
|
162
|
fill_in 'Start date', :with => ''
|
|
162
|
fill_in 'Start date', :with => ''
|
|
163
|
fill_in 'Due date', :with => '2012-04-01'
|
|
163
|
fill_in 'Due date', :with => '2012-04-01'
|
|
164
|
page.first('p#start_date_area img').click
|
|
164
|
page.first('p#start_date_area img').click
|
|
165
|
page.first("td.ui-datepicker-days-cell-over a").click
|
|
165
|
page.first("td.ui-datepicker-days-cell-over a").click
|
|
166
|
assert_equal '2012-04-01', page.find('input#issue_start_date').value
|
|
166
|
assert_equal '2012-04-01', page.find('input#issue_start_date').value
|
|
167
|
end
|
|
167
|
end
|
|
168
|
|
|
168
|
|
|
169
|
def test_preview_issue_description
|
|
169
|
def test_preview_issue_description
|
|
170
|
log_user('jsmith', 'jsmith')
|
|
170
|
log_user('jsmith', 'jsmith')
|
|
171
|
visit '/projects/ecookbook/issues/new'
|
|
171
|
visit '/projects/ecookbook/issues/new'
|
|
172
|
within('form#issue-form') do
|
|
172
|
within('form#issue-form') do
|
|
173
|
fill_in 'Subject', :with => 'new issue subject'
|
|
173
|
fill_in 'Subject', :with => 'new issue subject'
|
|
174
|
fill_in 'Description', :with => 'new issue description'
|
|
174
|
fill_in 'Description', :with => 'new issue description'
|
|
175
|
click_link 'Preview'
|
|
175
|
click_link 'Preview'
|
|
176
|
end
|
|
176
|
end
|
|
177
|
find 'div#preview fieldset', :visible => true, :text => 'new issue description'
|
|
177
|
find 'div#preview fieldset', :visible => true, :text => 'new issue description'
|
|
178
|
assert_difference 'Issue.count' do
|
|
178
|
assert_difference 'Issue.count' do
|
|
179
|
find('input[name=commit]').click
|
|
179
|
find('input[name=commit]').click
|
|
180
|
end
|
|
180
|
end
|
|
181
|
|
|
181
|
|
|
182
|
issue = Issue.order('id desc').first
|
|
182
|
issue = Issue.order('id desc').first
|
|
183
|
assert_equal 'new issue description', issue.description
|
|
183
|
assert_equal 'new issue description', issue.description
|
|
184
|
end
|
|
184
|
end
|
|
185
|
|
|
185
|
|
|
186
|
def test_update_issue_with_form_update
|
|
186
|
def test_update_issue_with_form_update
|
|
187
|
field = IssueCustomField.create!(
|
|
187
|
field = IssueCustomField.create!(
|
|
188
|
:field_format => 'string',
|
|
188
|
:field_format => 'string',
|
|
189
|
:name => 'Form update CF',
|
|
189
|
:name => 'Form update CF',
|
|
190
|
:is_for_all => true,
|
|
190
|
:is_for_all => true,
|
|
191
|
:trackers => Tracker.where(:name => 'Feature request')
|
|
191
|
:trackers => Tracker.where(:name => 'Feature request')
|
|
192
|
)
|
|
192
|
)
|
|
193
|
|
|
193
|
|
|
194
|
Role.non_member.add_permission! :edit_issues
|
|
194
|
Role.non_member.add_permission! :edit_issues
|
|
195
|
Role.non_member.remove_permission! :add_issues, :add_issue_notes
|
|
195
|
Role.non_member.remove_permission! :add_issues, :add_issue_notes
|
|
196
|
|
|
196
|
|
|
197
|
log_user('someone', 'foo')
|
|
197
|
log_user('someone', 'foo')
|
|
198
|
visit '/issues/1'
|
|
198
|
visit '/issues/1'
|
|
199
|
assert page.has_no_content?('Form update CF')
|
|
199
|
assert page.has_no_content?('Form update CF')
|
|
200
|
|
|
200
|
|
|
201
|
page.first(:link, 'Edit').click
|
|
201
|
page.first(:link, 'Edit').click
|
|
202
|
# the custom field should show up when changing tracker
|
|
202
|
# the custom field should show up when changing tracker
|
|
203
|
select 'Feature request', :from => 'Tracker'
|
|
203
|
select 'Feature request', :from => 'Tracker'
|
|
204
|
assert page.has_content?('Form update CF')
|
|
204
|
assert page.has_content?('Form update CF')
|
|
205
|
|
|
205
|
|
|
206
|
fill_in 'Form update', :with => 'CF value'
|
|
206
|
fill_in 'Form update', :with => 'CF value'
|
|
207
|
assert_no_difference 'Issue.count' do
|
|
207
|
assert_no_difference 'Issue.count' do
|
|
208
|
page.first(:button, 'Submit').click
|
|
208
|
page.first(:button, 'Submit').click
|
|
209
|
end
|
|
209
|
end
|
|
210
|
|
|
210
|
|
|
211
|
issue = Issue.find(1)
|
|
211
|
issue = Issue.find(1)
|
|
212
|
assert_equal 'CF value', issue.custom_field_value(field)
|
|
212
|
assert_equal 'CF value', issue.custom_field_value(field)
|
|
213
|
end
|
|
213
|
end
|
|
214
|
|
|
214
|
|
|
215
|
def test_remove_issue_watcher_from_sidebar
|
|
215
|
def test_remove_issue_watcher_from_sidebar
|
|
216
|
user = User.find(3)
|
|
216
|
user = User.find(3)
|
|
217
|
Watcher.create!(:watchable => Issue.find(1), :user => user)
|
|
217
|
Watcher.create!(:watchable => Issue.find(1), :user => user)
|
|
218
|
|
|
218
|
|
|
219
|
log_user('jsmith', 'jsmith')
|
|
219
|
log_user('jsmith', 'jsmith')
|
|
220
|
visit '/issues/1'
|
|
220
|
visit '/issues/1'
|
|
221
|
assert page.first('#sidebar').has_content?('Watchers (1)')
|
|
221
|
assert page.first('#sidebar').has_content?('Watchers (1)')
|
|
222
|
assert page.first('#sidebar').has_content?(user.name)
|
|
222
|
assert page.first('#sidebar').has_content?(user.name)
|
|
223
|
assert_difference 'Watcher.count', -1 do
|
|
223
|
assert_difference 'Watcher.count', -1 do
|
|
224
|
page.first('ul.watchers .user-3 a.delete').click
|
|
224
|
page.first('ul.watchers .user-3 a.delete').click
|
|
225
|
assert page.first('#sidebar').has_content?('Watchers (0)')
|
|
225
|
assert page.first('#sidebar').has_content?('Watchers (0)')
|
|
226
|
end
|
|
226
|
end
|
|
227
|
assert page.first('#sidebar').has_no_content?(user.name)
|
|
227
|
assert page.first('#sidebar').has_no_content?(user.name)
|
|
228
|
end
|
|
228
|
end
|
|
229
|
|
|
229
|
|
|
|
|
|
230
|
def test_watch_should_update_watchers_list
|
|
|
|
|
231
|
user = User.find(2)
|
|
|
|
|
232
|
log_user('jsmith', 'jsmith')
|
|
|
|
|
233
|
visit '/issues/1'
|
|
|
|
|
234
|
assert page.first('#sidebar').has_content?('Watchers (0)')
|
|
|
|
|
235
|
|
|
|
|
|
236
|
page.first('a.issue-1-watcher').click
|
|
|
|
|
237
|
assert page.first('#sidebar').has_content?('Watchers (1)')
|
|
|
|
|
238
|
assert page.first('#sidebar').has_content?(user.name)
|
|
|
|
|
239
|
end
|
|
|
|
|
240
|
|
|
230
|
def test_watch_issue_via_context_menu
|
|
241
|
def test_watch_issue_via_context_menu
|
|
231
|
log_user('jsmith', 'jsmith')
|
|
242
|
log_user('jsmith', 'jsmith')
|
|
232
|
visit '/issues'
|
|
243
|
visit '/issues'
|
|
233
|
assert page.has_css?('tr#issue-1')
|
|
244
|
assert page.has_css?('tr#issue-1')
|
|
234
|
find('tr#issue-1 td.updated_on').click
|
|
245
|
find('tr#issue-1 td.updated_on').click
|
|
235
|
page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
|
|
246
|
page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
|
|
236
|
assert_difference 'Watcher.count' do
|
|
247
|
assert_difference 'Watcher.count' do
|
|
237
|
within('#context-menu') do
|
|
248
|
within('#context-menu') do
|
|
238
|
click_link 'Watch'
|
|
249
|
click_link 'Watch'
|
|
239
|
end
|
|
250
|
end
|
|
240
|
# wait for ajax response
|
|
251
|
# wait for ajax response
|
|
241
|
assert page.has_css?('#context-menu .issue-1-watcher.icon-fav')
|
|
252
|
assert page.has_css?('#context-menu .issue-1-watcher.icon-fav')
|
|
242
|
assert page.has_css?('tr#issue-1')
|
|
253
|
assert page.has_css?('tr#issue-1')
|
|
243
|
end
|
|
254
|
end
|
|
244
|
assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
|
|
255
|
assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
|
|
245
|
end
|
|
256
|
end
|
|
246
|
|
|
257
|
|
|
247
|
def test_bulk_watch_issues_via_context_menu
|
|
258
|
def test_bulk_watch_issues_via_context_menu
|
|
248
|
log_user('jsmith', 'jsmith')
|
|
259
|
log_user('jsmith', 'jsmith')
|
|
249
|
visit '/issues'
|
|
260
|
visit '/issues'
|
|
250
|
assert page.has_css?('tr#issue-1')
|
|
261
|
assert page.has_css?('tr#issue-1')
|
|
251
|
assert page.has_css?('tr#issue-4')
|
|
262
|
assert page.has_css?('tr#issue-4')
|
|
252
|
find('tr#issue-1 input[type=checkbox]').click
|
|
263
|
find('tr#issue-1 input[type=checkbox]').click
|
|
253
|
find('tr#issue-4 input[type=checkbox]').click
|
|
264
|
find('tr#issue-4 input[type=checkbox]').click
|
|
254
|
page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
|
|
265
|
page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
|
|
255
|
assert_difference 'Watcher.count', 2 do
|
|
266
|
assert_difference 'Watcher.count', 2 do
|
|
256
|
within('#context-menu') do
|
|
267
|
within('#context-menu') do
|
|
257
|
click_link 'Watch'
|
|
268
|
click_link 'Watch'
|
|
258
|
end
|
|
269
|
end
|
|
259
|
# wait for ajax response
|
|
270
|
# wait for ajax response
|
|
260
|
assert page.has_css?('#context-menu .issue-bulk-watcher.icon-fav')
|
|
271
|
assert page.has_css?('#context-menu .issue-bulk-watcher.icon-fav')
|
|
261
|
assert page.has_css?('tr#issue-1')
|
|
272
|
assert page.has_css?('tr#issue-1')
|
|
262
|
assert page.has_css?('tr#issue-4')
|
|
273
|
assert page.has_css?('tr#issue-4')
|
|
263
|
end
|
|
274
|
end
|
|
264
|
assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
|
|
275
|
assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
|
|
265
|
assert Issue.find(4).watched_by?(User.find_by_login('jsmith'))
|
|
276
|
assert Issue.find(4).watched_by?(User.find_by_login('jsmith'))
|
|
266
|
end
|
|
277
|
end
|
|
267
|
end
|
|
278
|
end
|