mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-27 12:28:48 +01:00
Merge pull request #10 from mattr-/allow-comma-in-project-names
Allow comma in project names
This commit is contained in:
commit
0b88c72570
5 changed files with 13 additions and 10 deletions
|
|
@ -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}\''
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,9 @@ Feature: Manage the list of projects
|
|||
Then the project "very busy" should be above the project "test"
|
||||
|
||||
@selenium
|
||||
Scenario: Cannot add a project with comma in the name
|
||||
Scenario: Can add a project with comma in the name
|
||||
When I go to the projects page
|
||||
And I submit a new project with name "foo,bar"
|
||||
Then I should see "Name cannot contain the comma"
|
||||
Then I should see "foo,bar"
|
||||
And the badge should show 4
|
||||
And the project list badge for "active" projects should show 4
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ class ProjectXmlApiTest < ActionController::IntegrationTest
|
|||
|
||||
def test_fails_with_comma_in_name
|
||||
authenticated_post_xml_to_project_create "<request><project><name>foo,bar</name></project></request>"
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue