diff --git a/app/models/profile.rb b/app/models/profile.rb index b0e7cefad..d45c29fbb 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -40,7 +40,9 @@ class Profile < ActiveRecord::Base :image_url_small, :birthday, :gender, :bio, :location, :searchable, :date, :tag_string belongs_to :person - + before_validation do + self.tag_string = self.tag_string.split[0..4].join(' ') + end before_save do self.build_tags end diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index da464f770..0f2b2830f 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -188,9 +188,11 @@ describe Profile do @object.should be_valid 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.should_not be_valid + @object.save + @object.tags.count.should == 5 + puts @object.tag_string end it_should_behave_like 'it is taggable' end