Mercurial > hg > soundsoftware-site
comparison test/functional/project_enumerations_controller_test.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | 8661b858af72 |
children | 5e80956cc792 5f33065ddc4b |
comparison
equal
deleted
inserted
replaced
908:c6c2cbd0afee | 909:cbb26bc654de |
---|---|
1 require File.expand_path('../../test_helper', __FILE__) | 1 require File.expand_path('../../test_helper', __FILE__) |
2 | 2 |
3 class ProjectEnumerationsControllerTest < ActionController::TestCase | 3 class ProjectEnumerationsControllerTest < ActionController::TestCase |
4 fixtures :all | 4 fixtures :projects, :trackers, :issue_statuses, :issues, |
5 | 5 :enumerations, :users, :issue_categories, |
6 :projects_trackers, | |
7 :roles, | |
8 :member_roles, | |
9 :members, | |
10 :enabled_modules, | |
11 :workflows, | |
12 :custom_fields, :custom_fields_projects, | |
13 :custom_fields_trackers, :custom_values, | |
14 :time_entries | |
15 | |
6 def setup | 16 def setup |
7 @request.session[:user_id] = nil | 17 @request.session[:user_id] = nil |
8 Setting.default_language = 'en' | 18 Setting.default_language = 'en' |
9 end | 19 end |
10 | 20 |
74 :project => Project.find(1), | 84 :project => Project.find(1), |
75 :active => true | 85 :active => true |
76 }) | 86 }) |
77 assert project_activity_two.save | 87 assert project_activity_two.save |
78 | 88 |
79 | 89 |
80 put :update, :project_id => 1, :enumerations => { | 90 put :update, :project_id => 1, :enumerations => { |
81 project_activity.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # De-activate | 91 project_activity.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # De-activate |
82 project_activity_two.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"} # De-activate | 92 project_activity_two.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"} # De-activate |
83 } | 93 } |
84 | 94 |
100 assert !activity_two.active? | 110 assert !activity_two.active? |
101 end | 111 end |
102 | 112 |
103 def test_update_when_creating_new_activities_will_convert_existing_data | 113 def test_update_when_creating_new_activities_will_convert_existing_data |
104 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size | 114 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size |
105 | 115 |
106 @request.session[:user_id] = 2 # manager | 116 @request.session[:user_id] = 2 # manager |
107 put :update, :project_id => 1, :enumerations => { | 117 put :update, :project_id => 1, :enumerations => { |
108 "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"} # Design, De-activate | 118 "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"} # Design, De-activate |
109 } | 119 } |
110 assert_response :redirect | 120 assert_response :redirect |
124 TimeEntryActivity.create!({:name => parent.name, :project_id => 1, :position => parent.position, :active => true}) | 134 TimeEntryActivity.create!({:name => parent.name, :project_id => 1, :position => parent.position, :active => true}) |
125 TimeEntry.create!({:project_id => 1, :hours => 1.0, :user => User.find(1), :issue_id => 3, :activity_id => 10, :spent_on => '2009-01-01'}) | 135 TimeEntry.create!({:project_id => 1, :hours => 1.0, :user => User.find(1), :issue_id => 3, :activity_id => 10, :spent_on => '2009-01-01'}) |
126 | 136 |
127 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size | 137 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size |
128 assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size | 138 assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size |
129 | 139 |
130 @request.session[:user_id] = 2 # manager | 140 @request.session[:user_id] = 2 # manager |
131 put :update, :project_id => 1, :enumerations => { | 141 put :update, :project_id => 1, :enumerations => { |
132 "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design | 142 "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design |
133 "10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"} # Development, Change custom value | 143 "10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"} # Development, Change custom value |
134 } | 144 } |
162 assert_redirected_to '/projects/ecookbook/settings/activities' | 172 assert_redirected_to '/projects/ecookbook/settings/activities' |
163 | 173 |
164 assert_nil TimeEntryActivity.find_by_id(project_activity.id) | 174 assert_nil TimeEntryActivity.find_by_id(project_activity.id) |
165 assert_nil TimeEntryActivity.find_by_id(project_activity_two.id) | 175 assert_nil TimeEntryActivity.find_by_id(project_activity_two.id) |
166 end | 176 end |
167 | 177 |
168 def test_destroy_should_reassign_time_entries_back_to_the_system_activity | 178 def test_destroy_should_reassign_time_entries_back_to_the_system_activity |
169 @request.session[:user_id] = 2 # manager | 179 @request.session[:user_id] = 2 # manager |
170 project_activity = TimeEntryActivity.new({ | 180 project_activity = TimeEntryActivity.new({ |
171 :name => 'Project Specific Design', | 181 :name => 'Project Specific Design', |
172 :parent => TimeEntryActivity.find(9), | 182 :parent => TimeEntryActivity.find(9), |
174 :active => true | 184 :active => true |
175 }) | 185 }) |
176 assert project_activity.save | 186 assert project_activity.save |
177 assert TimeEntry.update_all("activity_id = '#{project_activity.id}'", ["project_id = ? AND activity_id = ?", 1, 9]) | 187 assert TimeEntry.update_all("activity_id = '#{project_activity.id}'", ["project_id = ? AND activity_id = ?", 1, 9]) |
178 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size | 188 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size |
179 | 189 |
180 delete :destroy, :project_id => 1 | 190 delete :destroy, :project_id => 1 |
181 assert_response :redirect | 191 assert_response :redirect |
182 assert_redirected_to '/projects/ecookbook/settings/activities' | 192 assert_redirected_to '/projects/ecookbook/settings/activities' |
183 | 193 |
184 assert_nil TimeEntryActivity.find_by_id(project_activity.id) | 194 assert_nil TimeEntryActivity.find_by_id(project_activity.id) |