Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validation of login ID is now case insensitive so no 'test' and 'TEST'.
- Loading branch information
sermoa
committed
Nov 25, 2008
1 parent
f305a1b
commit d9b5ea7
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
|
||
describe Person do | ||
|
||
describe "validation of login id" do | ||
|
||
before(:each) do | ||
@person = Person.create!(:login => 'test', :name => 'Test', | ||
:password => 'w00t!', :password_confirmation => 'w00t!', | ||
:email => 'test@test.com') | ||
end | ||
|
||
it "should allow a new person to be saved" do | ||
@person.errors_on(:login).should == [] | ||
end | ||
|
||
it "should allow letters and numbers in the login ID" do | ||
person2 = Person.new(:login => '123abc') | ||
person2.errors_on(:login).should == [] | ||
end | ||
|
||
it "should actually allow underscores and minus characters too" do | ||
person2 = Person.new(:login => '123_ab--c') | ||
person2.errors_on(:login).should == [] | ||
end | ||
|
||
it "should certainly not allow spaces in the login ID" do | ||
person2 = Person.new(:login => '123 ab -c') | ||
person2.errors_on(:login).should == ['can only contain letters and numbers'] | ||
end | ||
|
||
it "should not allow another person to be created with the same login ID" do | ||
person2 = Person.new(:login => 'test') | ||
person2.errors_on(:login).should == ['has already been taken'] | ||
end | ||
|
||
it "should not the same login ID, even if the case is different" do | ||
person2 = Person.new(:login => 'TEST') | ||
person2.errors_on(:login).should == ['has already been taken'] | ||
end | ||
|
||
end | ||
end |