From ba840423a6955efee1f5288851de9ce4d4601e5c Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Mon, 21 Jul 2014 15:19:15 -0500 Subject: [PATCH] one word tags, fix captcha two word mention --- app.rb | 2 +- models/site.rb | 4 ++-- models/tag.rb | 2 +- tests/acceptance_tests.rb | 10 +++++----- views/new.erb | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app.rb b/app.rb index 8e293377..c83347ce 100644 --- a/app.rb +++ b/app.rb @@ -374,7 +374,7 @@ post '/create' do session[:id] = @site.id redirect '/' else - @site.errors.add :captcha, 'You must type in the two words correctly! Try again.' if !recaptcha_is_valid + @site.errors.add :captcha, 'You must type in the captcha correctly! Try again.' if !recaptcha_is_valid erb :'/new' end diff --git a/models/site.rb b/models/site.rb index f1a1414c..4323cedd 100644 --- a/models/site.rb +++ b/models/site.rb @@ -425,12 +425,12 @@ class Site < Sequel::Model end if tag.match(/ /) - errors.add :tags, "Tag \"#{tag}\" cannot have more than one space between words." + errors.add :tags, "Tag \"#{tag}\" cannot have spaces." break end if tag.split(' ').length > Tag::NAME_WORDS_MAX - errors.add :tags, "Tag \"#{tag}\" cannot be more than two words." + errors.add :tags, "Tag \"#{tag}\" cannot be more than #{Tag::NAME_WORDS_MAX} word." break end diff --git a/models/tag.rb b/models/tag.rb index 89371cd9..4fca3b53 100644 --- a/models/tag.rb +++ b/models/tag.rb @@ -1,6 +1,6 @@ class Tag < Sequel::Model NAME_LENGTH_MAX = 20 - NAME_WORDS_MAX = 2 + NAME_WORDS_MAX = 1 many_to_many :sites def before_create diff --git a/tests/acceptance_tests.rb b/tests/acceptance_tests.rb index 68f21003..f1ea4ade 100644 --- a/tests/acceptance_tests.rb +++ b/tests/acceptance_tests.rb @@ -103,14 +103,14 @@ describe 'signup' do fill_in_valid fill_in 'tags', with: 'police officer, hi' click_button 'Create Home Page' - page.must_have_content /Tag.+cannot have more than one space/ + page.must_have_content /Tag.+cannot have spaces/ end it 'fails for tag with too many words' do fill_in_valid - fill_in 'tags', with: 'police officer club' + fill_in 'tags', with: 'police officer' click_button 'Create Home Page' - page.must_have_content /Tag.+cannot be more than two words/ + page.must_have_content /Tag.+cannot be more than #{Tag::NAME_WORDS_MAX} word/ end it "fails for tag longer than #{Tag::NAME_LENGTH_MAX} characters" do @@ -154,10 +154,10 @@ describe 'signup' do it 'succeeds with valid tags' do fill_in_valid - fill_in 'tags', with: 'derpie, shoujo manga' + fill_in 'tags', with: 'derpie, shoujo' click_button 'Create Home Page' page.must_have_content 'Your Feed' - Site.last.tags.collect {|t| t.name}.must_equal ['derpie', 'shoujo manga'] + Site.last.tags.collect {|t| t.name}.must_equal ['derpie', 'shoujo'] end end diff --git a/views/new.erb b/views/new.erb index 19c3e760..b0104dd2 100644 --- a/views/new.erb +++ b/views/new.erb @@ -61,7 +61,7 @@
-

You can optionally enter some tags! Tags will allow others to find your site based on your interests, or your site's theme. Separate multiple tags with commas. Don't think too hard about this, you can change them later. You can have a maximum of five tags, and tags can only contain letters (A-Z) and numbers (0-9). There is a two word per tag maximum.

+

You can optionally enter some tags! Tags will allow others to find your site based on your interests, or your site's theme. Separate multiple tags with commas. Don't think too hard about this, you can change them later. You can have a maximum of five tags, tags can only contain letters (A-Z) and numbers (0-9), no spaces.

Tags