diff --git a/app/models/todo.rb b/app/models/todo.rb index 7d5b71d5..f1164e1f 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -340,7 +340,10 @@ class Todo < ActiveRecord::Base # used by the REST API. will also work, this is renamed to add_tags in TodosController::TodoCreateParamsHelper::initialize def add_tags=(params) - tag_with params[:tag].inject([]) { |list, value| list << value[:name] } unless params[:tag].nil? + unless params[:tag].nil? + tag_list = params[:tag].inject([]) { |list, value| list << value[:name] } + tag_with tag_list.join(", ") + end end # Rich Todo API diff --git a/test/integration/todo_xml_api_test.rb b/test/integration/todo_xml_api_test.rb index bb25050d..0f88e52c 100644 --- a/test/integration/todo_xml_api_test.rb +++ b/test/integration/todo_xml_api_test.rb @@ -104,7 +104,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest assert_equal "starred, starred1, starred2", todo.tag_list assert todo.starred? end - + def test_post_create_todo_with_single_tag authenticated_post_xml_to_todo_create " @@ -122,6 +122,42 @@ class TodoXmlApiTest < ActionController::IntegrationTest assert_equal "tracks", todo.tag_list end + def test_post_create_todo_with_multiple_tags_and_space + # testing fix for #1229 + authenticated_post_xml_to_todo_create " + + this will succeed 3 + #{contexts(:office).id} + #{projects(:timemachine).id} + + foo + bar + bingo + +" + + assert_response :success + todo = @user.todos.find_by_description("this will succeed 3") + assert_not_nil todo + assert_equal "bar, bingo, foo", todo.tag_list + authenticated_post_xml_to_todo_create " + + this will succeed 4 + #{contexts(:office).id} + #{projects(:timemachine).id} + + foo + bar + bingo + +" + + assert_response :success + todo = @user.todos.find_by_description("this will succeed 4") + assert_not_nil todo + assert_equal "bar, bingo, foo", todo.tag_list + end + def test_post_create_todo_with_new_context authenticated_post_xml_to_todo_create "