mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-02 22:11:48 +01:00
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@265 a4c988fc-2ded-0310-b66e-134b36920a42
41 lines
1.2 KiB
Ruby
41 lines
1.2 KiB
Ruby
require File.dirname(__FILE__) + '/../test_helper'
|
|
|
|
class ProjectTest < Test::Unit::TestCase
|
|
fixtures :projects
|
|
|
|
def setup
|
|
@timemachine = Project.find(1)
|
|
@moremoney = Project.find(2)
|
|
end
|
|
|
|
def test_validate_presence_of_name
|
|
@timemachine.name = ""
|
|
assert !@timemachine.save
|
|
assert_equal 1, @timemachine.errors.count
|
|
assert_equal "project must have a name", @timemachine.errors.on(:name)
|
|
end
|
|
|
|
def test_validate_name_is_less_than_256
|
|
@timemachine.name = "a"*256
|
|
assert !@timemachine.save
|
|
assert_equal 1, @timemachine.errors.count
|
|
assert_equal "project name must be less than 256 characters", @timemachine.errors.on(:name)
|
|
end
|
|
|
|
def test_validate_name_is_unique
|
|
newproj = Project.new
|
|
newproj.name = "Build a working time machine"
|
|
assert !newproj.save
|
|
assert_equal 1, newproj.errors.count
|
|
assert_equal "already exists", newproj.errors.on(:name)
|
|
end
|
|
|
|
def test_validate_name_does_not_contain_slash
|
|
newproj = Project.new
|
|
newproj.name = "Save Earth/Mankind from Evil"
|
|
assert !newproj.save
|
|
assert_equal 1, newproj.errors.count
|
|
assert_equal "cannot contain the slash ('/') character", newproj.errors.on(:name)
|
|
end
|
|
|
|
end
|