Mercurial > hg > soundsoftware-site
comparison test/functional/trackers_controller_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. |
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 'trackers_controller' | |
20 | |
21 # Re-raise errors caught by the controller. | |
22 class TrackersController; def rescue_action(e) raise e end; end | |
23 | 19 |
24 class TrackersControllerTest < ActionController::TestCase | 20 class TrackersControllerTest < ActionController::TestCase |
25 fixtures :trackers, :projects, :projects_trackers, :users, :issues, :custom_fields | 21 fixtures :trackers, :projects, :projects_trackers, :users, :issues, :custom_fields |
26 | 22 |
27 def setup | 23 def setup |
28 @controller = TrackersController.new | |
29 @request = ActionController::TestRequest.new | |
30 @response = ActionController::TestResponse.new | |
31 User.current = nil | 24 User.current = nil |
32 @request.session[:user_id] = 1 # admin | 25 @request.session[:user_id] = 1 # admin |
33 end | 26 end |
34 | 27 |
35 def test_index | 28 def test_index |
59 def test_create | 52 def test_create |
60 assert_difference 'Tracker.count' do | 53 assert_difference 'Tracker.count' do |
61 post :create, :tracker => { :name => 'New tracker', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] } | 54 post :create, :tracker => { :name => 'New tracker', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] } |
62 end | 55 end |
63 assert_redirected_to :action => 'index' | 56 assert_redirected_to :action => 'index' |
64 tracker = Tracker.first(:order => 'id DESC') | 57 tracker = Tracker.order('id DESC').first |
65 assert_equal 'New tracker', tracker.name | 58 assert_equal 'New tracker', tracker.name |
66 assert_equal [1], tracker.project_ids.sort | 59 assert_equal [1], tracker.project_ids.sort |
67 assert_equal Tracker::CORE_FIELDS, tracker.core_fields | 60 assert_equal Tracker::CORE_FIELDS, tracker.core_fields |
68 assert_equal [1, 6], tracker.custom_field_ids.sort | 61 assert_equal [1, 6], tracker.custom_field_ids.sort |
69 assert_equal 0, tracker.workflow_rules.count | 62 assert_equal 0, tracker.workflow_rules.count |
72 def create_with_disabled_core_fields | 65 def create_with_disabled_core_fields |
73 assert_difference 'Tracker.count' do | 66 assert_difference 'Tracker.count' do |
74 post :create, :tracker => { :name => 'New tracker', :core_fields => ['assigned_to_id', 'fixed_version_id', ''] } | 67 post :create, :tracker => { :name => 'New tracker', :core_fields => ['assigned_to_id', 'fixed_version_id', ''] } |
75 end | 68 end |
76 assert_redirected_to :action => 'index' | 69 assert_redirected_to :action => 'index' |
77 tracker = Tracker.first(:order => 'id DESC') | 70 tracker = Tracker.order('id DESC').first |
78 assert_equal 'New tracker', tracker.name | 71 assert_equal 'New tracker', tracker.name |
79 assert_equal %w(assigned_to_id fixed_version_id), tracker.core_fields | 72 assert_equal %w(assigned_to_id fixed_version_id), tracker.core_fields |
80 end | 73 end |
81 | 74 |
82 def test_create_new_with_workflow_copy | 75 def test_create_new_with_workflow_copy |
89 assert_equal Tracker.find(1).workflow_rules.count, tracker.workflow_rules.count | 82 assert_equal Tracker.find(1).workflow_rules.count, tracker.workflow_rules.count |
90 end | 83 end |
91 | 84 |
92 def test_create_with_failure | 85 def test_create_with_failure |
93 assert_no_difference 'Tracker.count' do | 86 assert_no_difference 'Tracker.count' do |
94 post :create, :tracker => { :name => '', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] } | 87 post :create, :tracker => { :name => '', :project_ids => ['1', '', ''], |
88 :custom_field_ids => ['1', '6', ''] } | |
95 end | 89 end |
96 assert_response :success | 90 assert_response :success |
97 assert_template 'new' | 91 assert_template 'new' |
98 assert_error_tag :content => /name can't be blank/i | 92 assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i |
99 end | 93 end |
100 | 94 |
101 def test_edit | 95 def test_edit |
102 Tracker.find(1).project_ids = [1, 3] | 96 Tracker.find(1).project_ids = [1, 3] |
103 | 97 |
158 | 152 |
159 def test_update_with_failure | 153 def test_update_with_failure |
160 put :update, :id => 1, :tracker => { :name => '' } | 154 put :update, :id => 1, :tracker => { :name => '' } |
161 assert_response :success | 155 assert_response :success |
162 assert_template 'edit' | 156 assert_template 'edit' |
163 assert_error_tag :content => /name can't be blank/i | 157 assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i |
164 end | 158 end |
165 | 159 |
166 def test_move_lower | 160 def test_move_lower |
167 tracker = Tracker.find_by_position(1) | 161 tracker = Tracker.find_by_position(1) |
168 put :update, :id => 1, :tracker => { :move_to => 'lower' } | 162 put :update, :id => 1, :tracker => { :move_to => 'lower' } |