mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-31 13:15:17 +01:00
various small refactorings
This commit is contained in:
parent
10d3bc783c
commit
067db90d58
4 changed files with 90 additions and 43 deletions
|
|
@ -42,5 +42,33 @@ class IsTaggableTest < ActiveSupport::TestCase
|
|||
t.tag_with "a, b, e, f"
|
||||
assert_equal "a, b, e, f", t.tag_list, "should add e and f and remove c and d"
|
||||
end
|
||||
|
||||
def test_editing_using_taglist
|
||||
t = Todo.create(:description => "test", :context => Context.first)
|
||||
t.tag_list = "a, b, c"
|
||||
assert_equal 3, t.tags.count
|
||||
assert_equal "a, b, c", t.tag_list
|
||||
|
||||
|
||||
t.tag_list = "d, e"
|
||||
assert_equal 2, t.tags.count
|
||||
assert_equal "d, e", t.tag_list
|
||||
end
|
||||
|
||||
def test_tag_cast_to_string
|
||||
t = Todo.create(:description => "test", :context => Context.first)
|
||||
|
||||
obj = "tag"
|
||||
assert_equal ["tag"], t.tag_cast_to_string(obj)
|
||||
|
||||
obj = ["tag1", Tag.new(name: "tag2")]
|
||||
assert_equal ["tag1", "tag2"], t.tag_cast_to_string(obj)
|
||||
|
||||
obj = {a: "hash"}
|
||||
assert_raise(RuntimeError) { t.tag_cast_to_string(obj) }
|
||||
|
||||
obj = ["string", {a: "hash"}]
|
||||
assert_raise(RuntimeError) { t.tag_cast_to_string(obj) }
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue