##// END OF EJS Templates
Fixed UI tests....
Jean-Philippe Lang -
r12057:0a5632013f23
parent child
Show More
@@ -1,72 +1,72
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
2 # Copyright (C) 2006-2013 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('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19 require 'capybara/rails'
19 require 'capybara/rails'
20
20
21 Capybara.default_driver = :selenium
21 Capybara.default_driver = :selenium
22 Capybara.register_driver :selenium do |app|
22 Capybara.register_driver :selenium do |app|
23 # Use the following driver definition to test locally using Chrome
23 # Use the following driver definition to test locally using Chrome
24 # (also requires chromedriver to be in PATH)
24 # (also requires chromedriver to be in PATH)
25 # Capybara::Selenium::Driver.new(app, :browser => :chrome)
25 # Capybara::Selenium::Driver.new(app, :browser => :chrome)
26 # Add :switches => %w[--lang=en] to force default browser locale to English
26 # Add :switches => %w[--lang=en] to force default browser locale to English
27 # Default for Selenium remote driver is to connect to local host on port 4444
27 # Default for Selenium remote driver is to connect to local host on port 4444
28 # This can be change using :url => 'http://localhost:9195' if necessary
28 # This can be change using :url => 'http://localhost:9195' if necessary
29 # PhantomJS 1.8 now directly supports Webdriver Wire API,
29 # PhantomJS 1.8 now directly supports Webdriver Wire API,
30 # simply run it with `phantomjs --webdriver 4444`
30 # simply run it with `phantomjs --webdriver 4444`
31 # Add :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.internet_explorer)
31 # Add :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.internet_explorer)
32 # to run on Selenium Grid Hub with IE
32 # to run on Selenium Grid Hub with IE
33 Capybara::Selenium::Driver.new(app, :browser => :remote)
33 Capybara::Selenium::Driver.new(app, :browser => :remote)
34 end
34 end
35
35
36 # default: 2
36 # default: 2
37 Capybara.default_wait_time = 20
37 Capybara.default_wait_time = 2
38
38
39 DatabaseCleaner.strategy = :truncation
39 DatabaseCleaner.strategy = :truncation
40
40
41 module Redmine
41 module Redmine
42 module UiTest
42 module UiTest
43 # Base class for UI tests
43 # Base class for UI tests
44 class Base < ActionDispatch::IntegrationTest
44 class Base < ActionDispatch::IntegrationTest
45 include Capybara::DSL
45 include Capybara::DSL
46
46
47 # Stop ActiveRecord from wrapping tests in transactions
47 # Stop ActiveRecord from wrapping tests in transactions
48 # Transactional fixtures do not work with Selenium tests, because Capybara
48 # Transactional fixtures do not work with Selenium tests, because Capybara
49 # uses a separate server thread, which the transactions would be hidden
49 # uses a separate server thread, which the transactions would be hidden
50 self.use_transactional_fixtures = false
50 self.use_transactional_fixtures = false
51
51
52 # Should not depend on locale since Redmine displays login page
52 # Should not depend on locale since Redmine displays login page
53 # using default browser locale which depend on system locale for "real" browsers drivers
53 # using default browser locale which depend on system locale for "real" browsers drivers
54 def log_user(login, password)
54 def log_user(login, password)
55 visit '/my/page'
55 visit '/my/page'
56 assert_equal '/login', current_path
56 assert_equal '/login', current_path
57 within('#login-form form') do
57 within('#login-form form') do
58 fill_in 'username', :with => login
58 fill_in 'username', :with => login
59 fill_in 'password', :with => password
59 fill_in 'password', :with => password
60 find('input[name=login]').click
60 find('input[name=login]').click
61 end
61 end
62 assert_equal '/my/page', current_path
62 assert_equal '/my/page', current_path
63 end
63 end
64
64
65 teardown do
65 teardown do
66 Capybara.reset_sessions! # Forget the (simulated) browser state
66 Capybara.reset_sessions! # Forget the (simulated) browser state
67 Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
67 Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
68 DatabaseCleaner.clean
68 DatabaseCleaner.clean
69 end
69 end
70 end
70 end
71 end
71 end
72 end
72 end
@@ -1,265 +1,264
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
2 # Copyright (C) 2006-2013 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 select '', :from => 'Assignee'
37 fill_in 'Searchable field', :with => 'Value for field 2'
36 fill_in 'Searchable field', :with => 'Value for field 2'
38 # 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
39 find('input[name=commit]').click
38 find('input[name=commit]').click
40 end
39 end
41
40
42 # find created issue
41 # find created issue
43 issue = Issue.find_by_subject("new test issue")
42 issue = Issue.find_by_subject("new test issue")
44 assert_kind_of Issue, issue
43 assert_kind_of Issue, issue
45
44
46 # check redirection
45 # check redirection
47 find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created."
46 find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created."
48 assert_equal issue_path(:id => issue), current_path
47 assert_equal issue_path(:id => issue), current_path
49
48
50 # check issue attributes
49 # check issue attributes
51 assert_equal 'jsmith', issue.author.login
50 assert_equal 'jsmith', issue.author.login
52 assert_equal 1, issue.project.id
51 assert_equal 1, issue.project.id
53 assert_equal IssueStatus.find_by_name('New'), issue.status
52 assert_equal IssueStatus.find_by_name('New'), issue.status
54 assert_equal Tracker.find_by_name('Bug'), issue.tracker
53 assert_equal Tracker.find_by_name('Bug'), issue.tracker
55 assert_equal IssuePriority.find_by_name('Low'), issue.priority
54 assert_equal IssuePriority.find_by_name('Low'), issue.priority
56 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'))
57 end
56 end
58
57
59 def test_create_issue_with_form_update
58 def test_create_issue_with_form_update
60 field1 = IssueCustomField.create!(
59 field1 = IssueCustomField.create!(
61 :field_format => 'string',
60 :field_format => 'string',
62 :name => 'Field1',
61 :name => 'Field1',
63 :is_for_all => true,
62 :is_for_all => true,
64 :trackers => Tracker.find_all_by_id([1, 2])
63 :trackers => Tracker.find_all_by_id([1, 2])
65 )
64 )
66 field2 = IssueCustomField.create!(
65 field2 = IssueCustomField.create!(
67 :field_format => 'string',
66 :field_format => 'string',
68 :name => 'Field2',
67 :name => 'Field2',
69 :is_for_all => true,
68 :is_for_all => true,
70 :trackers => Tracker.find_all_by_id(2)
69 :trackers => Tracker.find_all_by_id(2)
71 )
70 )
72
71
73 Role.non_member.add_permission! :add_issues
72 Role.non_member.add_permission! :add_issues
74 Role.non_member.remove_permission! :edit_issues, :add_issue_notes
73 Role.non_member.remove_permission! :edit_issues, :add_issue_notes
75
74
76 log_user('someone', 'foo')
75 log_user('someone', 'foo')
77 visit '/projects/ecookbook/issues/new'
76 visit '/projects/ecookbook/issues/new'
78 assert page.has_no_content?(field2.name)
77 assert page.has_no_content?(field2.name)
79 assert page.has_content?(field1.name)
78 assert page.has_content?(field1.name)
80
79
81 fill_in 'Subject', :with => 'New test issue'
80 fill_in 'Subject', :with => 'New test issue'
82 fill_in 'Description', :with => 'New test issue description'
81 fill_in 'Description', :with => 'New test issue description'
83 fill_in field1.name, :with => 'CF1 value'
82 fill_in field1.name, :with => 'CF1 value'
84 select 'Low', :from => 'Priority'
83 select 'Low', :from => 'Priority'
85
84
86 # field2 should show up when changing tracker
85 # field2 should show up when changing tracker
87 select 'Feature request', :from => 'Tracker'
86 select 'Feature request', :from => 'Tracker'
88 assert page.has_content?(field2.name)
87 assert page.has_content?(field2.name)
89 assert page.has_content?(field1.name)
88 assert page.has_content?(field1.name)
90
89
91 fill_in field2.name, :with => 'CF2 value'
90 fill_in field2.name, :with => 'CF2 value'
92 assert_difference 'Issue.count' do
91 assert_difference 'Issue.count' do
93 page.first(:button, 'Create').click
92 page.first(:button, 'Create').click
94 end
93 end
95
94
96 issue = Issue.order('id desc').first
95 issue = Issue.order('id desc').first
97 assert_equal 'New test issue', issue.subject
96 assert_equal 'New test issue', issue.subject
98 assert_equal 'New test issue description', issue.description
97 assert_equal 'New test issue description', issue.description
99 assert_equal 'Low', issue.priority.name
98 assert_equal 'Low', issue.priority.name
100 assert_equal 'CF1 value', issue.custom_field_value(field1)
99 assert_equal 'CF1 value', issue.custom_field_value(field1)
101 assert_equal 'CF2 value', issue.custom_field_value(field2)
100 assert_equal 'CF2 value', issue.custom_field_value(field2)
102 end
101 end
103
102
104 def test_create_issue_with_watchers
103 def test_create_issue_with_watchers
105 user = User.generate!(:firstname => 'Some', :lastname => 'Watcher')
104 user = User.generate!(:firstname => 'Some', :lastname => 'Watcher')
106 assert_equal 'Some Watcher', user.name
105 assert_equal 'Some Watcher', user.name
107 log_user('jsmith', 'jsmith')
106 log_user('jsmith', 'jsmith')
108 visit '/projects/ecookbook/issues/new'
107 visit '/projects/ecookbook/issues/new'
109 fill_in 'Subject', :with => 'Issue with watchers'
108 fill_in 'Subject', :with => 'Issue with watchers'
110 # Add a project member as watcher
109 # Add a project member as watcher
111 check 'Dave Lopper'
110 check 'Dave Lopper'
112 # Search for another user
111 # Search for another user
113 assert page.has_no_css?('form#new-watcher-form')
112 assert page.has_no_css?('form#new-watcher-form')
114 assert page.has_no_content?('Some Watcher')
113 assert page.has_no_content?('Some Watcher')
115 click_link 'Search for watchers to add'
114 click_link 'Search for watchers to add'
116 within('form#new-watcher-form') do
115 within('form#new-watcher-form') do
117 assert page.has_content?('Some One')
116 assert page.has_content?('Some One')
118 fill_in 'user_search', :with => 'watch'
117 fill_in 'user_search', :with => 'watch'
119 assert page.has_no_content?('Some One')
118 assert page.has_no_content?('Some One')
120 check 'Some Watcher'
119 check 'Some Watcher'
121 click_button 'Add'
120 click_button 'Add'
122 end
121 end
123 assert page.has_css?('form#issue-form')
122 assert page.has_css?('form#issue-form')
124 assert page.has_css?('p#watchers_form')
123 assert page.has_css?('p#watchers_form')
125 using_wait_time(30) do
124 using_wait_time(30) do
126 within('span#watchers_inputs') do
125 within('span#watchers_inputs') do
127 within("label#issue_watcher_user_ids_#{user.id}") do
126 within("label#issue_watcher_user_ids_#{user.id}") do
128 assert has_content?('Some Watcher'), "No watcher content"
127 assert has_content?('Some Watcher'), "No watcher content"
129 end
128 end
130 end
129 end
131 end
130 end
132 assert_difference 'Issue.count' do
131 assert_difference 'Issue.count' do
133 find('input[name=commit]').click
132 find('input[name=commit]').click
134 end
133 end
135
134
136 issue = Issue.order('id desc').first
135 issue = Issue.order('id desc').first
137 assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort
136 assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort
138 end
137 end
139
138
140 def test_create_issue_start_due_date
139 def test_create_issue_start_due_date
141 with_settings :default_issue_start_date_to_creation_date => 0 do
140 with_settings :default_issue_start_date_to_creation_date => 0 do
142 log_user('jsmith', 'jsmith')
141 log_user('jsmith', 'jsmith')
143 visit '/projects/ecookbook/issues/new'
142 visit '/projects/ecookbook/issues/new'
144 assert_equal "", page.find('input#issue_start_date').value
143 assert_equal "", page.find('input#issue_start_date').value
145 assert_equal "", page.find('input#issue_due_date').value
144 assert_equal "", page.find('input#issue_due_date').value
146 page.first('p#start_date_area img').click
145 page.first('p#start_date_area img').click
147 page.first("td.ui-datepicker-days-cell-over a").click
146 page.first("td.ui-datepicker-days-cell-over a").click
148 assert_equal Date.today.to_s, page.find('input#issue_start_date').value
147 assert_equal Date.today.to_s, page.find('input#issue_start_date').value
149 page.first('p#due_date_area img').click
148 page.first('p#due_date_area img').click
150 page.first("td.ui-datepicker-days-cell-over a").click
149 page.first("td.ui-datepicker-days-cell-over a").click
151 assert_equal Date.today.to_s, page.find('input#issue_due_date').value
150 assert_equal Date.today.to_s, page.find('input#issue_due_date').value
152 end
151 end
153 end
152 end
154
153
155 def test_create_issue_start_due_date_default
154 def test_create_issue_start_due_date_default
156 log_user('jsmith', 'jsmith')
155 log_user('jsmith', 'jsmith')
157 visit '/projects/ecookbook/issues/new'
156 visit '/projects/ecookbook/issues/new'
158 fill_in 'Start date', :with => '2012-04-01'
157 fill_in 'Start date', :with => '2012-04-01'
159 fill_in 'Due date', :with => ''
158 fill_in 'Due date', :with => ''
160 page.first('p#due_date_area img').click
159 page.first('p#due_date_area img').click
161 page.first("td.ui-datepicker-days-cell-over a").click
160 page.first("td.ui-datepicker-days-cell-over a").click
162 assert_equal '2012-04-01', page.find('input#issue_due_date').value
161 assert_equal '2012-04-01', page.find('input#issue_due_date').value
163
162
164 fill_in 'Start date', :with => ''
163 fill_in 'Start date', :with => ''
165 fill_in 'Due date', :with => '2012-04-01'
164 fill_in 'Due date', :with => '2012-04-01'
166 page.first('p#start_date_area img').click
165 page.first('p#start_date_area img').click
167 page.first("td.ui-datepicker-days-cell-over a").click
166 page.first("td.ui-datepicker-days-cell-over a").click
168 assert_equal '2012-04-01', page.find('input#issue_start_date').value
167 assert_equal '2012-04-01', page.find('input#issue_start_date').value
169 end
168 end
170
169
171 def test_preview_issue_description
170 def test_preview_issue_description
172 log_user('jsmith', 'jsmith')
171 log_user('jsmith', 'jsmith')
173 visit '/projects/ecookbook/issues/new'
172 visit '/projects/ecookbook/issues/new'
174 within('form#issue-form') do
173 within('form#issue-form') do
175 fill_in 'Subject', :with => 'new issue subject'
174 fill_in 'Subject', :with => 'new issue subject'
176 fill_in 'Description', :with => 'new issue description'
175 fill_in 'Description', :with => 'new issue description'
177 click_link 'Preview'
176 click_link 'Preview'
178 end
177 end
179 find 'div#preview fieldset', :visible => true, :text => 'new issue description'
178 find 'div#preview fieldset', :visible => true, :text => 'new issue description'
180 assert_difference 'Issue.count' do
179 assert_difference 'Issue.count' do
181 find('input[name=commit]').click
180 find('input[name=commit]').click
182 end
181 end
183
182
184 issue = Issue.order('id desc').first
183 issue = Issue.order('id desc').first
185 assert_equal 'new issue description', issue.description
184 assert_equal 'new issue description', issue.description
186 end
185 end
187
186
188 def test_update_issue_with_form_update
187 def test_update_issue_with_form_update
189 field = IssueCustomField.create!(
188 field = IssueCustomField.create!(
190 :field_format => 'string',
189 :field_format => 'string',
191 :name => 'Form update CF',
190 :name => 'Form update CF',
192 :is_for_all => true,
191 :is_for_all => true,
193 :trackers => Tracker.find_all_by_name('Feature request')
192 :trackers => Tracker.find_all_by_name('Feature request')
194 )
193 )
195
194
196 Role.non_member.add_permission! :edit_issues
195 Role.non_member.add_permission! :edit_issues
197 Role.non_member.remove_permission! :add_issues, :add_issue_notes
196 Role.non_member.remove_permission! :add_issues, :add_issue_notes
198
197
199 log_user('someone', 'foo')
198 log_user('someone', 'foo')
200 visit '/issues/1'
199 visit '/issues/1'
201 assert page.has_no_content?('Form update CF')
200 assert page.has_no_content?('Form update CF')
202
201
203 page.first(:link, 'Update').click
202 page.first(:link, 'Edit').click
204 # the custom field should show up when changing tracker
203 # the custom field should show up when changing tracker
205 select 'Feature request', :from => 'Tracker'
204 select 'Feature request', :from => 'Tracker'
206 assert page.has_content?('Form update CF')
205 assert page.has_content?('Form update CF')
207
206
208 fill_in 'Form update', :with => 'CF value'
207 fill_in 'Form update', :with => 'CF value'
209 assert_no_difference 'Issue.count' do
208 assert_no_difference 'Issue.count' do
210 page.first(:button, 'Submit').click
209 page.first(:button, 'Submit').click
211 end
210 end
212
211
213 issue = Issue.find(1)
212 issue = Issue.find(1)
214 assert_equal 'CF value', issue.custom_field_value(field)
213 assert_equal 'CF value', issue.custom_field_value(field)
215 end
214 end
216
215
217 def test_remove_issue_watcher_from_sidebar
216 def test_remove_issue_watcher_from_sidebar
218 user = User.find(3)
217 user = User.find(3)
219 Watcher.create!(:watchable => Issue.find(1), :user => user)
218 Watcher.create!(:watchable => Issue.find(1), :user => user)
220
219
221 log_user('jsmith', 'jsmith')
220 log_user('jsmith', 'jsmith')
222 visit '/issues/1'
221 visit '/issues/1'
223 assert page.first('#sidebar').has_content?('Watchers (1)')
222 assert page.first('#sidebar').has_content?('Watchers (1)')
224 assert page.first('#sidebar').has_content?(user.name)
223 assert page.first('#sidebar').has_content?(user.name)
225 assert_difference 'Watcher.count', -1 do
224 assert_difference 'Watcher.count', -1 do
226 page.first('ul.watchers .user-3 a.delete').click
225 page.first('ul.watchers .user-3 a.delete').click
227 assert page.first('#sidebar').has_content?('Watchers (0)')
226 assert page.first('#sidebar').has_content?('Watchers (0)')
228 end
227 end
229 assert page.first('#sidebar').has_no_content?(user.name)
228 assert page.first('#sidebar').has_no_content?(user.name)
230 end
229 end
231
230
232 def test_watch_issue_via_context_menu
231 def test_watch_issue_via_context_menu
233 log_user('jsmith', 'jsmith')
232 log_user('jsmith', 'jsmith')
234 visit '/issues'
233 visit '/issues'
235 assert page.has_css?('tr#issue-1')
234 assert page.has_css?('tr#issue-1')
236 find('tr#issue-1 td.updated_on').click
235 find('tr#issue-1 td.updated_on').click
237 page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
236 page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
238 assert_difference 'Watcher.count' do
237 assert_difference 'Watcher.count' do
239 within('#context-menu') do
238 within('#context-menu') do
240 click_link 'Watch'
239 click_link 'Watch'
241 end
240 end
242 assert page.has_css?('tr#issue-1')
241 assert page.has_css?('tr#issue-1')
243 end
242 end
244 assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
243 assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
245 end
244 end
246
245
247 def test_bulk_watch_issues_via_context_menu
246 def test_bulk_watch_issues_via_context_menu
248 log_user('jsmith', 'jsmith')
247 log_user('jsmith', 'jsmith')
249 visit '/issues'
248 visit '/issues'
250 assert page.has_css?('tr#issue-1')
249 assert page.has_css?('tr#issue-1')
251 assert page.has_css?('tr#issue-4')
250 assert page.has_css?('tr#issue-4')
252 find('tr#issue-1 input[type=checkbox]').click
251 find('tr#issue-1 input[type=checkbox]').click
253 find('tr#issue-4 input[type=checkbox]').click
252 find('tr#issue-4 input[type=checkbox]').click
254 page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
253 page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
255 assert_difference 'Watcher.count', 2 do
254 assert_difference 'Watcher.count', 2 do
256 within('#context-menu') do
255 within('#context-menu') do
257 click_link 'Watch'
256 click_link 'Watch'
258 end
257 end
259 assert page.has_css?('tr#issue-1')
258 assert page.has_css?('tr#issue-1')
260 assert page.has_css?('tr#issue-4')
259 assert page.has_css?('tr#issue-4')
261 end
260 end
262 assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
261 assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
263 assert Issue.find(4).watched_by?(User.find_by_login('jsmith'))
262 assert Issue.find(4).watched_by?(User.find_by_login('jsmith'))
264 end
263 end
265 end
264 end
General Comments 0
You need to be logged in to leave comments. Login now