Fix tags_helper, add specs

This commit is contained in:
Sarah Mei 2012-01-29 11:46:51 -08:00
parent 782885c58d
commit e4fa8d8466
2 changed files with 21 additions and 3 deletions

View file

@ -1,9 +1,9 @@
module TagsHelper module TagsHelper
def looking_for_tag_link def looking_for_tag_link
return if @search_query.include?('@') || normalized_tag_name.blank? return if search_query.include?('@') || normalized_tag_name.blank?
content_tag('h4') do content_tag('h4') do
content_tag('small') do content_tag('small') do
t('.looking_for', :tag_link => tag_link).html_safe t('people.index.looking_for', :tag_link => tag_link).html_safe
end end
end end
end end

View file

@ -0,0 +1,18 @@
require 'spec_helper'
describe TagsHelper do
describe '#looking_for_tag_link' do
it 'returns nil if there is a @ in the query' do
helper.stub(:search_query).and_return('foo@bar.com')
helper.looking_for_tag_link.should be_nil
end
it 'returns nil if it normalizes to blank' do
helper.stub(:search_query).and_return('++')
helper.looking_for_tag_link.should be_nil
end
it 'returns a link to the tag otherwise' do
helper.stub(:search_query).and_return('foo')
helper.looking_for_tag_link.should include(helper.tag_link)
end
end
end