fix for >5 tag logic

This commit is contained in:
Kyle Drake 2014-06-08 21:20:09 -07:00
parent 51ccd367c4
commit 575189656b
2 changed files with 9 additions and 2 deletions

View file

@ -353,8 +353,8 @@ class Site < Sequel::Model
new_tags.compact! new_tags.compact!
@new_filtered_tags = [] @new_filtered_tags = []
if new_tags.length > 5 if ((new? ? 0 : tags_dataset.count) + new_tags.length > 5)
error.add :tags, 'Cannot have more than 5 tags.' errors.add :tags, 'Cannot have more than 5 tags for your site.'
end end
new_tags.each do |tag| new_tags.each do |tag|

View file

@ -113,6 +113,13 @@ describe 'signup' do
page.must_have_content /Tag.+cannot be more than two words/ page.must_have_content /Tag.+cannot be more than two words/
end end
it 'fails for too many tags' do
fill_in_valid
fill_in 'tags', with: 'one, two, three, four, five, six'
click_button 'Create Home Page'
page.must_have_content /Cannot have more than \d tags for your site/
end
it 'succeeds with no tags' do it 'succeeds with no tags' do
fill_in_valid fill_in_valid
fill_in 'tags', with: '' fill_in 'tags', with: ''