fix regression by last commit

Signed-off-by: Reinier Balt <lrbalt@gmail.com>
This commit is contained in:
Reinier Balt 2011-09-12 22:58:39 +02:00
parent f5cabbf74d
commit 8fe5552d64
2 changed files with 8 additions and 8 deletions

View file

@ -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)

View file

@ -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 "<todo><description>this will fail</description><context_id type='integer'>-16</context_id><project_id type='integer'>-11</project_id></todo>"
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