mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-29 21:38:49 +01:00
Merge pull request #153 from kytrinyx/tag-to-s
Override #to_s on Tag for simplified joining
This commit is contained in:
commit
a94ea6b0f2
3 changed files with 11 additions and 2 deletions
|
|
@ -127,7 +127,7 @@ module TodosHelper
|
|||
end
|
||||
|
||||
def tag_list_text(todo=@todo)
|
||||
todo.tags.collect{|t| t.name}.join(', ')
|
||||
todo.tags.join(', ')
|
||||
end
|
||||
|
||||
def tag_span (tag, mobile=false)
|
||||
|
|
|
|||
|
|
@ -30,4 +30,8 @@ class Tag < ActiveRecord::Base
|
|||
@label ||= name.gsub(' ', '-')
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,5 +45,10 @@ class TagTest < ActiveSupport::TestCase
|
|||
def test_tag_label
|
||||
assert_equal 'one-two-three', Tag.new(:name => 'one two three').label
|
||||
end
|
||||
|
||||
|
||||
def test_tag_as_string
|
||||
tags = [Tag.new(:name => 'tag1'), Tag.new(:name => 'tag2')]
|
||||
assert_equal 'tag1, tag2', tags.join(', ')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue