mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-07 09:48:50 +01:00
ticket: 487 - make sure to remove extraneous spaces from project names when saving record
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@608 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
fbcf864bde
commit
dd2f530f74
2 changed files with 17 additions and 1 deletions
|
|
@ -86,7 +86,10 @@ class Project < ActiveRecord::Base
|
|||
complete!
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def name=(value)
|
||||
self[:name] = value.gsub(/\s{2,}/, " ").strip
|
||||
end
|
||||
end
|
||||
|
||||
class NullProject
|
||||
|
|
|
|||
|
|
@ -39,6 +39,19 @@ class ProjectTest < Test::Rails::TestCase
|
|||
assert_equal "cannot contain the comma (',') character", newproj.errors.on(:name)
|
||||
end
|
||||
|
||||
def test_name_removes_extra_spaces
|
||||
newproj = Project.new
|
||||
newproj.name = "These Words Have Proximity Issues "
|
||||
assert newproj.save
|
||||
assert_equal 0, newproj.errors.count
|
||||
assert_equal "These Words Have Proximity Issues", newproj.name
|
||||
|
||||
# and on update...
|
||||
@timemachine.name = " a time machine needs lots of spaaaaaaace "
|
||||
assert @timemachine.save
|
||||
assert_equal "a time machine needs lots of spaaaaaaace", @timemachine.name
|
||||
end
|
||||
|
||||
def test_project_initial_state_is_active
|
||||
assert_equal :active, @timemachine.current_state
|
||||
assert @timemachine.active?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue