Mercurial > hg > soundsoftware-site
comparison test/functional/issues_controller_transaction_test.rb @ 1526:404aa68d4227
Merge from live branch
author | Chris Cannam |
---|---|
date | Thu, 11 Sep 2014 12:46:20 +0100 |
parents | dffacf8a6908 |
children |
comparison
equal
deleted
inserted
replaced
1493:a5f2bdf3b486 | 1526:404aa68d4227 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2014 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. |
17 | 17 |
18 require File.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
19 require 'issues_controller' | 19 require 'issues_controller' |
20 | 20 |
21 class IssuesControllerTransactionTest < ActionController::TestCase | 21 class IssuesControllerTransactionTest < ActionController::TestCase |
22 tests IssuesController | |
22 fixtures :projects, | 23 fixtures :projects, |
23 :users, | 24 :users, |
24 :roles, | 25 :roles, |
25 :members, | 26 :members, |
26 :member_roles, | 27 :member_roles, |
44 :queries | 45 :queries |
45 | 46 |
46 self.use_transactional_fixtures = false | 47 self.use_transactional_fixtures = false |
47 | 48 |
48 def setup | 49 def setup |
49 @controller = IssuesController.new | |
50 @request = ActionController::TestRequest.new | |
51 @response = ActionController::TestResponse.new | |
52 User.current = nil | 50 User.current = nil |
53 end | 51 end |
54 | 52 |
55 def test_update_stale_issue_should_not_update_the_issue | 53 def test_update_stale_issue_should_not_update_the_issue |
56 issue = Issue.find(2) | 54 issue = Issue.find(2) |
102 end | 100 end |
103 end | 101 end |
104 | 102 |
105 assert_response :success | 103 assert_response :success |
106 assert_template 'edit' | 104 assert_template 'edit' |
107 attachment = Attachment.first(:order => 'id DESC') | 105 attachment = Attachment.order('id DESC').first |
108 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token} | 106 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token} |
109 assert_tag 'span', :content => /testfile.txt/ | 107 assert_tag 'input', :attributes => {:name => 'attachments[p0][filename]', :value => 'testfile.txt'} |
110 end | 108 end |
111 | 109 |
112 def test_update_stale_issue_without_notes_should_not_show_add_notes_option | 110 def test_update_stale_issue_without_notes_should_not_show_add_notes_option |
113 issue = Issue.find(2) | 111 issue = Issue.find(2) |
114 @request.session[:user_id] = 2 | 112 @request.session[:user_id] = 2 |
189 end | 187 end |
190 | 188 |
191 assert_response 302 | 189 assert_response 302 |
192 issue = Issue.find(1) | 190 issue = Issue.find(1) |
193 assert_equal 4, issue.fixed_version_id | 191 assert_equal 4, issue.fixed_version_id |
194 journal = Journal.first(:order => 'id DESC') | 192 journal = Journal.order('id DESC').first |
195 assert_equal 'overwrite_conflict_resolution', journal.notes | 193 assert_equal 'overwrite_conflict_resolution', journal.notes |
196 assert journal.details.any? | 194 assert journal.details.any? |
197 end | 195 end |
198 | 196 |
199 def test_update_stale_issue_with_add_notes_conflict_resolution_should_update | 197 def test_update_stale_issue_with_add_notes_conflict_resolution_should_update |
210 end | 208 end |
211 | 209 |
212 assert_response 302 | 210 assert_response 302 |
213 issue = Issue.find(1) | 211 issue = Issue.find(1) |
214 assert_nil issue.fixed_version_id | 212 assert_nil issue.fixed_version_id |
215 journal = Journal.first(:order => 'id DESC') | 213 journal = Journal.order('id DESC').first |
216 assert_equal 'add_notes_conflict_resolution', journal.notes | 214 assert_equal 'add_notes_conflict_resolution', journal.notes |
217 assert journal.details.empty? | 215 assert journal.details.empty? |
218 end | 216 end |
219 | 217 |
220 def test_update_stale_issue_with_cancel_conflict_resolution_should_redirect_without_updating | 218 def test_update_stale_issue_with_cancel_conflict_resolution_should_redirect_without_updating |
252 assert_select 'option[value=?][selected=selected]', TimeEntryActivity.first.id | 250 assert_select 'option[value=?][selected=selected]', TimeEntryActivity.first.id |
253 end | 251 end |
254 end | 252 end |
255 | 253 |
256 def test_index_should_rescue_invalid_sql_query | 254 def test_index_should_rescue_invalid_sql_query |
257 Query.any_instance.stubs(:statement).returns("INVALID STATEMENT") | 255 IssueQuery.any_instance.stubs(:statement).returns("INVALID STATEMENT") |
258 | 256 |
259 get :index | 257 get :index |
260 assert_response 500 | 258 assert_response 500 |
261 assert_tag 'p', :content => /An error occurred/ | 259 assert_tag 'p', :content => /An error occurred/ |
262 assert_nil session[:query] | 260 assert_nil session[:query] |