From 92c8cfe61ae7752377efa7b9af0a9e72606ff2f2 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Tue, 13 Sep 2011 07:11:33 +0200 Subject: [PATCH] fix another regression by the previous two commits :-( Signed-off-by: Reinier Balt --- app/controllers/todos_controller.rb | 4 ++-- test/functional/stats_controller_test.rb | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index bdbf356f..dcbf8e06 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -74,7 +74,7 @@ class TodosController < ApplicationController project = current_user.projects.find_or_create_by_name(p.project_name) @new_project_created = project.new_record_before_save? @todo.project_id = project.id - elsif !p.project_id.nil? + elsif !(p.project_id.nil? || p.project_id.blank?) project = current_user.projects.find_by_id(p.project_id) @todo.errors.add(:project, "unknown") if project.nil? end @@ -84,7 +84,7 @@ class TodosController < ApplicationController @new_context_created = context.new_record_before_save? @not_done_todos = [@todo] if @new_context_created @todo.context_id = context.id - elsif !p.context_id.nil? + elsif !(p.context_id.nil? || p.context_id.blank?) context = current_user.contexts.find_by_id(p.context_id) @todo.errors.add(:context, "unknown") if context.nil? end diff --git a/test/functional/stats_controller_test.rb b/test/functional/stats_controller_test.rb index 3b0fb30e..a187b79e 100755 --- a/test/functional/stats_controller_test.rb +++ b/test/functional/stats_controller_test.rb @@ -6,7 +6,7 @@ class StatsController; def rescue_action(e) raise e end; end class StatsControllerTest < ActionController::TestCase fixtures :users, :preferences, :projects, :contexts, :todos, :recurring_todos, :recurring_todos, :tags, :taggings - + def setup @controller = StatsController.new @request = ActionController::TestRequest.new @@ -17,12 +17,12 @@ class StatsControllerTest < ActionController::TestCase def test_truth assert true end - + def test_get_index_when_not_logged_in get :index assert_redirected_to :controller => 'login', :action => 'login' end - + def test_get_index login_as(:admin_user) get :index @@ -59,23 +59,23 @@ class StatsControllerTest < ActionController::TestCase assert_equal 17, assigns['actions'].count assert_equal 4, assigns['tags_count'] assert_equal 2, assigns['unique_tags_count'] - assert_equal 2.week.ago.at_midnight, assigns['first_action'].created_at.at_midnight + assert_equal 2.week.ago.utc.at_midnight, assigns['first_action'].created_at.utc.at_midnight end - + def test_downdrill login_as(:admin_user) - + # drill down without parameters get :show_selected_actions_from_chart assert_response :not_found assert_template nil - + # get week 0-1 for actions visible running get :show_selected_actions_from_chart, :id => 'avrt', :index => 0 assert_response :success assert_template "stats/show_selection_from_chart" - # get week 0 and further for actions visible running + # get week 0 and further for actions visible running get :show_selected_actions_from_chart, :id => 'avrt_end', :index => 0 assert_response :success assert_template "stats/show_selection_from_chart"