@@ -2,7 +2,7 require File.expand_path('../../test_helper', __FILE__) | |||||
2 |
|
2 | |||
3 | class ProjectEnumerationsControllerTest < ActionController::TestCase |
|
3 | class ProjectEnumerationsControllerTest < ActionController::TestCase | |
4 | fixtures :all |
|
4 | fixtures :all | |
5 |
|
5 | |||
6 | def setup |
|
6 | def setup | |
7 | @request.session[:user_id] = nil |
|
7 | @request.session[:user_id] = nil | |
8 | Setting.default_language = 'en' |
|
8 | Setting.default_language = 'en' | |
@@ -76,7 +76,7 class ProjectEnumerationsControllerTest < ActionController::TestCase | |||||
76 | }) |
|
76 | }) | |
77 | assert project_activity_two.save |
|
77 | assert project_activity_two.save | |
78 |
|
78 | |||
79 |
|
79 | |||
80 | put :update, :project_id => 1, :enumerations => { |
|
80 | put :update, :project_id => 1, :enumerations => { | |
81 | project_activity.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # De-activate |
|
81 | 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 |
|
82 | project_activity_two.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"} # De-activate | |
@@ -102,7 +102,7 class ProjectEnumerationsControllerTest < ActionController::TestCase | |||||
102 |
|
102 | |||
103 | def test_update_when_creating_new_activities_will_convert_existing_data |
|
103 | 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 |
|
104 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size | |
105 |
|
105 | |||
106 | @request.session[:user_id] = 2 # manager |
|
106 | @request.session[:user_id] = 2 # manager | |
107 | put :update, :project_id => 1, :enumerations => { |
|
107 | put :update, :project_id => 1, :enumerations => { | |
108 | "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"} # Design, De-activate |
|
108 | "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"} # Design, De-activate | |
@@ -126,7 +126,7 class ProjectEnumerationsControllerTest < ActionController::TestCase | |||||
126 |
|
126 | |||
127 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size |
|
127 | 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 |
|
128 | assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size | |
129 |
|
129 | |||
130 | @request.session[:user_id] = 2 # manager |
|
130 | @request.session[:user_id] = 2 # manager | |
131 | put :update, :project_id => 1, :enumerations => { |
|
131 | put :update, :project_id => 1, :enumerations => { | |
132 | "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design |
|
132 | "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design | |
@@ -164,7 +164,7 class ProjectEnumerationsControllerTest < ActionController::TestCase | |||||
164 | assert_nil TimeEntryActivity.find_by_id(project_activity.id) |
|
164 | assert_nil TimeEntryActivity.find_by_id(project_activity.id) | |
165 | assert_nil TimeEntryActivity.find_by_id(project_activity_two.id) |
|
165 | assert_nil TimeEntryActivity.find_by_id(project_activity_two.id) | |
166 | end |
|
166 | end | |
167 |
|
167 | |||
168 | def test_destroy_should_reassign_time_entries_back_to_the_system_activity |
|
168 | def test_destroy_should_reassign_time_entries_back_to_the_system_activity | |
169 | @request.session[:user_id] = 2 # manager |
|
169 | @request.session[:user_id] = 2 # manager | |
170 | project_activity = TimeEntryActivity.new({ |
|
170 | project_activity = TimeEntryActivity.new({ | |
@@ -176,7 +176,7 class ProjectEnumerationsControllerTest < ActionController::TestCase | |||||
176 | assert project_activity.save |
|
176 | assert project_activity.save | |
177 | assert TimeEntry.update_all("activity_id = '#{project_activity.id}'", ["project_id = ? AND activity_id = ?", 1, 9]) |
|
177 | 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 |
|
178 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size | |
179 |
|
179 | |||
180 | delete :destroy, :project_id => 1 |
|
180 | delete :destroy, :project_id => 1 | |
181 | assert_response :redirect |
|
181 | assert_response :redirect | |
182 | assert_redirected_to '/projects/ecookbook/settings/activities' |
|
182 | assert_redirected_to '/projects/ecookbook/settings/activities' |
General Comments 0
You need to be logged in to leave comments.
Login now