mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-06 01:08:50 +01:00
another set of dynamic finder migrations. All non-cucumber tests pass
This commit is contained in:
parent
64a198d45a
commit
ef91dd0c64
18 changed files with 66 additions and 66 deletions
|
|
@ -4,39 +4,39 @@ class TagTest < ActiveSupport::TestCase
|
|||
fixtures :tags
|
||||
|
||||
def test_find_or_create_with_single_word
|
||||
tag = Tag.find_or_create_by_name("test")
|
||||
tag = Tag.where(:name => "test").first_or_create
|
||||
assert !tag.new_record?
|
||||
end
|
||||
|
||||
def test_find_or_create_with_space
|
||||
tag = Tag.find_or_create_by_name("test test")
|
||||
tag = Tag.where(:name => "test test").first_or_create
|
||||
assert !tag.new_record?
|
||||
end
|
||||
|
||||
def test_find_or_create_with_dot
|
||||
tag = Tag.find_or_create_by_name("a.b.c")
|
||||
tag = Tag.where(:name => "a.b.c").first_or_create
|
||||
assert !tag.new_record?
|
||||
end
|
||||
|
||||
def test_find_or_create_with_number_as_string
|
||||
tag = Tag.find_or_create_by_name("12343")
|
||||
tag = Tag.where(:name => "12343").first_or_create
|
||||
assert !tag.new_record?
|
||||
|
||||
tag = Tag.find_or_create_by_name("8.1.2")
|
||||
tag = Tag.where(:name => "8.1.2").first_or_create
|
||||
assert !tag.new_record?
|
||||
end
|
||||
|
||||
def test_tag_name_always_lowercase
|
||||
tag = Tag.find_or_create_by_name("UPPER")
|
||||
tag = Tag.where(:name => "UPPER").first_or_create
|
||||
assert !tag.new_record?
|
||||
|
||||
upper = Tag.find_by_name("upper")
|
||||
upper = Tag.where(:name => "upper").first
|
||||
assert_not_nil upper
|
||||
assert upper.name == "upper"
|
||||
end
|
||||
|
||||
def test_tag_name_stripped_of_spaces
|
||||
tag = Tag.find_or_create_by_name(" strip spaces ")
|
||||
tag = Tag.where(:name => " strip spaces ").first_or_create
|
||||
assert !tag.new_record?
|
||||
|
||||
assert tag.name == "strip spaces"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ class TaggingTest < ActiveSupport::TestCase
|
|||
|
||||
tagging.destroy
|
||||
|
||||
assert_nil Tag.find_by_name("hello")
|
||||
assert_nil Tag.where(:name => "hello").first
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -276,9 +276,9 @@ class TodoTest < ActiveSupport::TestCase
|
|||
todo.tag_list = "a, b, c"
|
||||
todo.save!
|
||||
|
||||
tag_a = Tag.find_by_name("a")
|
||||
tag_b = Tag.find_by_name("b")
|
||||
tag_c = Tag.find_by_name("c")
|
||||
tag_a = Tag.where(:name => "a").first
|
||||
tag_b = Tag.where(:name => "b").first
|
||||
tag_c = Tag.where(:name => "c").first
|
||||
|
||||
todos_with_a = Todo.with_tag(tag_a)
|
||||
assert_equal 1, todos_with_a.count
|
||||
|
|
@ -292,7 +292,7 @@ class TodoTest < ActiveSupport::TestCase
|
|||
todo2.tag_list = "a, c, d"
|
||||
todo2.save!
|
||||
|
||||
tag_d = Tag.find_by_name("d")
|
||||
tag_d = Tag.where(:name => "d").first
|
||||
|
||||
todos_with_a = Todo.with_tag(tag_a)
|
||||
assert_equal 2, todos_with_a.count
|
||||
|
|
@ -310,10 +310,10 @@ class TodoTest < ActiveSupport::TestCase
|
|||
todo2.tag_list = "a, c, d"
|
||||
todo2.save!
|
||||
|
||||
tag_a = Tag.find_by_name("a")
|
||||
tag_b = Tag.find_by_name("b")
|
||||
tag_c = Tag.find_by_name("c")
|
||||
tag_d = Tag.find_by_name("d")
|
||||
tag_a = Tag.where(:name => "a").first
|
||||
tag_b = Tag.where(:name => "b").first
|
||||
tag_c = Tag.where(:name => "c").first
|
||||
tag_d = Tag.where(:name => "d").first
|
||||
|
||||
# overlapping tags
|
||||
tag_ids = [tag_a.id, tag_c.id]
|
||||
|
|
@ -335,8 +335,8 @@ class TodoTest < ActiveSupport::TestCase
|
|||
todo2.tag_list = "a, c, d"
|
||||
todo2.save!
|
||||
|
||||
tag_a_id = Tag.find_by_name("a").id
|
||||
tag_b_id = Tag.find_by_name("b").id
|
||||
tag_a_id = Tag.where(:name => "a").first.id
|
||||
tag_b_id = Tag.where(:name => "b").first.id
|
||||
|
||||
todos_with_a_and_b = Todo.with_tags([tag_a_id]).with_tags([tag_b_id])
|
||||
assert_equal 1, todos_with_a_and_b.count
|
||||
|
|
@ -352,9 +352,9 @@ class TodoTest < ActiveSupport::TestCase
|
|||
todo2.tag_list = "a, c, d"
|
||||
todo2.save!
|
||||
|
||||
tag_a_id = Tag.find_by_name("a").id
|
||||
tag_b_id = Tag.find_by_name("b").id
|
||||
tag_c_id = Tag.find_by_name("c").id
|
||||
tag_a_id = Tag.where(:name => "a").first.id
|
||||
tag_b_id = Tag.where(:name => "b").first.id
|
||||
tag_c_id = Tag.where(:name => "c").first.id
|
||||
|
||||
todos_with_aORc_and_b = Todo.with_tags([tag_a_id, tag_c_id]).with_tags([tag_b_id])
|
||||
assert_equal 1, todos_with_aORc_and_b.count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue