--- src/app/models/user.rb | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/app/models/user.rb b/src/app/models/user.rb index fe429bd..8e007bc 100644 --- a/src/app/models/user.rb +++ b/src/app/models/user.rb @@ -27,4 +27,7 @@ class User < ActiveRecord::Base
belongs_to :quota, :autosave => true accepts_nested_attributes_for :quota + + validates_length_of :first_name, :maximum => 255 + validates_length_of :last_name, :maximum => 255 end
--- src/spec/models/user_spec.rb | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/spec/models/user_spec.rb b/src/spec/models/user_spec.rb index af88688..e7e69c7 100644 --- a/src/spec/models/user_spec.rb +++ b/src/spec/models/user_spec.rb @@ -43,4 +43,20 @@ describe User do user.should_not be_valid end
+ it "should not be valid if first name is too long" do + u = Factory(:tuser) + u.first_name = ('a' * 256) + u.valid?.should be_false + u.errors[:first_name].should_not be_nil + u.errors[:first_name].should =~ /^is too long.*/ + end + + it "should not be valid if last name is too long" do + u = Factory(:tuser) + u.last_name = ('a' * 256) + u.valid?.should be_false + u.errors[:last_name].should_not be_nil + u.errors[:last_name].should =~ /^is too long.*/ + end + end
On 11/04/2010 09:50 PM, Mohammed Morsi wrote:
src/spec/models/user_spec.rb | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/spec/models/user_spec.rb b/src/spec/models/user_spec.rb index af88688..e7e69c7 100644 --- a/src/spec/models/user_spec.rb +++ b/src/spec/models/user_spec.rb @@ -43,4 +43,20 @@ describe User do user.should_not be_valid end
- it "should not be valid if first name is too long" do
- u = Factory(:tuser)
- u.first_name = ('a' * 256)
- u.valid?.should be_false
- u.errors[:first_name].should_not be_nil
- u.errors[:first_name].should =~ /^is too long.*/
- end
- it "should not be valid if last name is too long" do
- u = Factory(:tuser)
- u.last_name = ('a' * 256)
- u.valid?.should be_false
- u.errors[:last_name].should_not be_nil
- u.errors[:last_name].should =~ /^is too long.*/
- end
- end
ACK to both (rebase will be required because of conflict with tomas's patch)
deltacloud-devel@lists.fedorahosted.org