From 55bf457740965a7032b9dbe4bbcbed6eb49cea7f Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Thu, 1 Sep 2011 21:05:19 -0500 Subject: [PATCH] Allow projects to have commas in their name. This removes the validation that checks to make sure there is no comma in the name, and updates the tests to match. --- app/models/project.rb | 1 - test/functional/projects_controller_test.rb | 4 ++-- test/integration/project_xml_api_test.rb | 4 +++- test/unit/project_test.rb | 8 ++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 00854394..5fd60f24 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -14,7 +14,6 @@ class Project < ActiveRecord::Base validates_presence_of :name validates_length_of :name, :maximum => 255 validates_uniqueness_of :name, :scope => "user_id" - validates_does_not_contain :name, :string => ',' acts_as_list :scope => 'user_id = #{user_id} AND state = \'#{state}\'' diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index f0a456dd..32729605 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -48,8 +48,8 @@ class ProjectsControllerTest < TodoContainerControllerTestBase assert_ajax_create_increments_count 'My New Project' end - def test_create_with_comma_in_name_does_not_increment_number_of_projects - assert_ajax_create_does_not_increment_count 'foo,bar' + def test_create_with_comma_in_name_increments_number_of_projects + assert_ajax_create_increments_count 'foo,bar' end def test_todo_state_is_project_hidden_after_hiding_project diff --git a/test/integration/project_xml_api_test.rb b/test/integration/project_xml_api_test.rb index 87560d7a..4111ebb2 100644 --- a/test/integration/project_xml_api_test.rb +++ b/test/integration/project_xml_api_test.rb @@ -41,7 +41,9 @@ class ProjectXmlApiTest < ActionController::IntegrationTest def test_fails_with_comma_in_name authenticated_post_xml_to_project_create "foo,bar" - assert_response_and_body 404, "Name cannot contain the comma (',') character" + assert_response :created + project1 = Project.find_by_name("foo,bar") + assert_not_nil project1, "expected project 'foo,bar' to be created" end def test_creates_new_project diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index 70a518b9..bafa5425 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -31,12 +31,12 @@ class ProjectTest < ActiveSupport::TestCase assert_equal "already exists", newproj.errors.on(:name) end - def test_validate_name_does_not_contain_comma + def test_validate_name_can_contain_comma newproj = Project.new newproj.name = "Buy iPhones for Luke,bsag,David Allen" - assert !newproj.save - assert_equal 1, newproj.errors.count - assert_equal "cannot contain the comma (',') character", newproj.errors.on(:name) + assert newproj.save + assert_equal 0, newproj.errors.count + assert_equal "Buy iPhones for Luke,bsag,David Allen", newproj.name end def test_name_removes_extra_spaces