From 8fe5552d6466e4849383ff387a96cf87aa55fc0d Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Mon, 12 Sep 2011 22:58:39 +0200 Subject: [PATCH] fix regression by last commit Signed-off-by: Reinier Balt --- app/controllers/todos_controller.rb | 8 +++++--- test/integration/todo_xml_api_test.rb | 8 +++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index ab81272a..bdbf356f 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -89,7 +89,7 @@ class TodosController < ApplicationController @todo.errors.add(:context, "unknown") if context.nil? end - if @saved + if @todo.errors.empty? @todo.starred= (params[:new_todo_starred]||"").include? "true" @todo.add_predecessor_list(predecessor_list) @@ -97,9 +97,11 @@ class TodosController < ApplicationController # Fix for #977 because AASM overrides @state on creation specified_state = @todo.state @saved = @todo.save - end - @todo.update_state_from_project if @saved + @todo.update_state_from_project if @saved + else + @saved = false + end unless (@saved == false) || tag_list.blank? @todo.tag_with(tag_list) diff --git a/test/integration/todo_xml_api_test.rb b/test/integration/todo_xml_api_test.rb index 7dbfee19..dc35fa33 100644 --- a/test/integration/todo_xml_api_test.rb +++ b/test/integration/todo_xml_api_test.rb @@ -37,17 +37,15 @@ class TodoXmlApiTest < ActionController::IntegrationTest def test_post_create_todo_with_wrong_project_and_context_id authenticated_post_xml_to_todo_create "this will fail-16-11" assert_response 422 + assert_xml_select 'errors' do + assert_select 'error', 2 + end end private def authenticated_post_xml_to_todo_create(postdata = @@valid_postdata, user = users(:other_user).login, password = 'sesame') authenticated_post_xml "/todos", user, password, postdata - assert_xml_select 'errors' do - assert_select 'error', 2, 'Project unknown' - assert_select 'error', 2, 'Context unknown' - end - end end \ No newline at end of file