annotate .svn/pristine/da/da78d3fb1e68f0f6756399b65dd60a2b75d92cb5.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

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