From 575189656bf51170d66577eb88028489346d8fab Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sun, 8 Jun 2014 21:20:09 -0700 Subject: [PATCH] fix for >5 tag logic --- models/site.rb | 4 ++-- tests/acceptance_tests.rb | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/models/site.rb b/models/site.rb index e2a6c931..410af5f9 100644 --- a/models/site.rb +++ b/models/site.rb @@ -353,8 +353,8 @@ class Site < Sequel::Model new_tags.compact! @new_filtered_tags = [] - if new_tags.length > 5 - error.add :tags, 'Cannot have more than 5 tags.' + if ((new? ? 0 : tags_dataset.count) + new_tags.length > 5) + errors.add :tags, 'Cannot have more than 5 tags for your site.' end new_tags.each do |tag| diff --git a/tests/acceptance_tests.rb b/tests/acceptance_tests.rb index 429344ec..54cc46a2 100644 --- a/tests/acceptance_tests.rb +++ b/tests/acceptance_tests.rb @@ -113,6 +113,13 @@ describe 'signup' do page.must_have_content /Tag.+cannot be more than two words/ 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 fill_in_valid fill_in 'tags', with: ''