Merge pull request #151 from kytrinyx/tag-label

Add Tag#label method
This commit is contained in:
Matt Rogers 2013-02-18 18:31:41 -08:00
commit 0df2faf553
4 changed files with 10 additions and 2 deletions

View file

@ -3,7 +3,7 @@ module RecurringTodosHelper
def recurring_todo_tag_list
tags_except_starred = @recurring_todo.tags.reject{|t| t.name == Todo::STARRED_TAG_NAME}
tag_list = tags_except_starred.
collect{|t| content_tag(:span,link_to(t.name, tag_path(t.name)), :class => "tag #{t.name.gsub(' ','-')}")}.
collect{|t| content_tag(:span,link_to(t.name, tag_path(t.name)), :class => "tag #{t.label}")}.
join('')
return content_tag :span, tag_list.html_safe, :class => "tags"
end

View file

@ -131,7 +131,7 @@ module TodosHelper
end
def tag_span (tag, mobile=false)
content_tag(:span, :class => "tag #{tag.name.gsub(' ','-')}") { link_to(tag.name, tag_path(tag.name, :format => mobile ? :m : nil)) }
content_tag(:span, :class => "tag #{tag.label}") { link_to(tag.name, tag_path(tag.name, :format => mobile ? :m : nil)) }
end
def tag_list(todo=@todo, mobile=false)

View file

@ -26,4 +26,8 @@ class Tag < ActiveRecord::Base
taggings.create :taggable => taggable, :user => user
end
def label
@label ||= name.gsub(' ', '-')
end
end

View file

@ -41,5 +41,9 @@ class TagTest < ActiveSupport::TestCase
assert tag.name == "strip spaces"
end
def test_tag_label
assert_equal 'one-two-three', Tag.new(:name => 'one two three').label
end
end