fix tests
This commit is contained in:
@@ -31,12 +31,14 @@ class TagAutocompleteTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "#search_fuzzy" do
|
context "#search_fuzzy" do
|
||||||
setup do
|
setup do
|
||||||
|
CurrentUser.stubs(:id).returns(1)
|
||||||
|
|
||||||
@tags = [
|
@tags = [
|
||||||
create(:tag, name: "abcdef", post_count: 1),
|
create(:tag, name: "abcde", post_count: 1),
|
||||||
create(:tag, name: "abcdzz", post_count: 2),
|
create(:tag, name: "abcdz", post_count: 2),
|
||||||
|
|
||||||
# one char mismatch
|
# one char mismatch
|
||||||
create(:tag, name: "abcezz", post_count: 2),
|
create(:tag, name: "abcez", post_count: 2),
|
||||||
|
|
||||||
# too long
|
# too long
|
||||||
create(:tag, name: "abcdefghijk", post_count: 2),
|
create(:tag, name: "abcdefghijk", post_count: 2),
|
||||||
@@ -45,18 +47,18 @@ class TagAutocompleteTest < ActiveSupport::TestCase
|
|||||||
create(:tag, name: "bbcdef", post_count: 2),
|
create(:tag, name: "bbcdef", post_count: 2),
|
||||||
|
|
||||||
# zero post count
|
# zero post count
|
||||||
create(:tag, name: "abcdyy", post_count: 0),
|
create(:tag, name: "abcdy", post_count: 0),
|
||||||
|
|
||||||
# completely different
|
# completely different
|
||||||
create(:tag, name: "bbbbbb")
|
create(:tag, name: "bbbbb")
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
should "find the tags" do
|
should "find the tags" do
|
||||||
expected = [
|
expected = [
|
||||||
|
@tags[0],
|
||||||
@tags[1],
|
@tags[1],
|
||||||
@tags[2],
|
@tags[2]
|
||||||
@tags[0]
|
|
||||||
].map(&:name)
|
].map(&:name)
|
||||||
assert_equal(expected, subject.search_fuzzy("abcd", 3).map(&:name))
|
assert_equal(expected, subject.search_fuzzy("abcd", 3).map(&:name))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -280,9 +280,7 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "find nothing for bad IDs" do
|
should "find nothing for bad IDs" do
|
||||||
assert_raises(PixivApiClient::BadIDError) do
|
assert_artist_not_found("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=32049358")
|
||||||
assert_artist_not_found("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=32049358")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user