strip more than 5 tags when updating profile so people with broken profiles can update again

This commit is contained in:
maxwell 2011-03-29 10:56:11 -07:00
parent aa478ddd5c
commit 5392b5c6ef
2 changed files with 7 additions and 3 deletions

View file

@ -40,7 +40,9 @@ class Profile < ActiveRecord::Base
:image_url_small, :birthday, :gender, :bio, :location, :searchable, :date, :tag_string :image_url_small, :birthday, :gender, :bio, :location, :searchable, :date, :tag_string
belongs_to :person belongs_to :person
before_validation do
self.tag_string = self.tag_string.split[0..4].join(' ')
end
before_save do before_save do
self.build_tags self.build_tags
end end

View file

@ -188,9 +188,11 @@ describe Profile do
@object.should be_valid @object.should be_valid
end end
it 'allows no more than 5 tags' do it 'strips more than 5 tags' do
@object.tag_string = '#one #two #three #four #five #six' @object.tag_string = '#one #two #three #four #five #six'
@object.should_not be_valid @object.save
@object.tags.count.should == 5
puts @object.tag_string
end end
it_should_behave_like 'it is taggable' it_should_behave_like 'it is taggable'
end end