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