fixed tests

This commit is contained in:
albert
2013-02-20 16:24:59 -05:00
parent 2954118663
commit b03e889cdd
5 changed files with 15 additions and 7 deletions

View File

@@ -67,11 +67,11 @@ class Artist < ActiveRecord::Base
end
def other_names_array
other_names.split(/ /)
other_names.try(:split, / /)
end
def other_names_comma
other_names_array.join(", ")
other_names_array.try(:join, ", ")
end
def other_names_comma=(string)

View File

@@ -339,7 +339,7 @@ class Tag < ActiveRecord::Base
module RelationMethods
def update_related
return unless should_update_related?
CurrentUser.scoped(User.find(1), "127.0.0.1") do
CurrentUser.scoped(User.first, "127.0.0.1") do
self.related_tags = RelatedTagCalculator.calculate_from_sample_to_array(name).join(" ")
end
self.related_tags_updated_at = Time.now

View File

@@ -111,8 +111,8 @@ class ArtistTest < ActiveSupport::TestCase
end
should "normalize its other names" do
artist = FactoryGirl.create(:artist, :name => "a1", :other_names => "aaa, bbb, ccc ddd")
assert_equal("aaa bbb ccc_ddd", artist.other_names)
artist = FactoryGirl.create(:artist, :name => "a1", :other_names_comma => "aaa, bbb, ccc ddd")
assert_equal("aaa, bbb, ccc_ddd", artist.other_names_comma)
end
should "search on its name should return results" do
@@ -121,7 +121,7 @@ class ArtistTest < ActiveSupport::TestCase
end
should "search on other names should return matches" do
artist = FactoryGirl.create(:artist, :name => "artist", :other_names => "aaa, ccc ddd")
artist = FactoryGirl.create(:artist, :name => "artist", :other_names_comma => "aaa, ccc ddd")
assert_nil(Artist.other_names_match("artist").first)
assert_not_nil(Artist.other_names_match("aaa").first)
assert_not_nil(Artist.other_names_match("ccc_ddd").first)

View File

@@ -183,7 +183,7 @@ class PoolTest < ActiveSupport::TestCase
should "normalize its name" do
@pool.update_attributes(:name => "A B")
assert_equal("a_b", @pool.name)
assert_equal("A_B", @pool.name)
end
should "normalize its post ids" do

View File

@@ -38,6 +38,10 @@ class PostTest < ActiveSupport::TestCase
end
context "Deleting a post" do
setup do
Danbooru.config.stubs(:blank_tag_search_fast_count).returns(nil)
end
context "that is status locked" do
setup do
@post = FactoryGirl.create(:post)
@@ -862,6 +866,10 @@ class PostTest < ActiveSupport::TestCase
context "Counting:" do
context "Creating a post" do
setup do
Danbooru.config.stubs(:blank_tag_search_fast_count).returns(nil)
end
should "increment the post count" do
assert_equal(0, Post.fast_count(""))
post = FactoryGirl.create(:post, :tag_string => "aaa bbb")