diff --git a/app/models/profile.rb b/app/models/profile.rb index bfbb535e5..622a3e919 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -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 diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index b9406c5f3..2e7379fd1 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -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)