Fixed Bug #5593. Added length validation to location in profile model with maximum length 255.

This commit is contained in:
Sam Radhakrishnan 2015-02-02 01:10:35 +05:30
parent b4ff1f97e7
commit a12c0d83c0
2 changed files with 13 additions and 0 deletions

View file

@ -32,6 +32,7 @@ class Profile < ActiveRecord::Base
validates :first_name, :length => { :maximum => 32 }
validates :last_name, :length => { :maximum => 32 }
validates :location, :length => { :maximum =>255 }
validates_format_of :first_name, :with => /\A[^;]+\z/, :allow_blank => true
validates_format_of :last_name, :with => /\A[^;]+\z/, :allow_blank => true

View file

@ -112,6 +112,18 @@ describe Profile, :type => :model do
end
end
describe "of location" do
it "can be 255 characters long" do
profile = FactoryGirl.build(:profile, :location => "a"*255)
expect(profile).to be_valid
end
it "cannot be 256 characters" do
profile = FactoryGirl.build(:profile, :location => "a"*256)
expect(profile).not_to be_valid
end
end
describe '#image_url=' do
before do
@profile = FactoryGirl.build(:profile)