diff --git a/app/models/artist.rb b/app/models/artist.rb index 31400ef29..e0ecc2019 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -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) diff --git a/app/models/tag.rb b/app/models/tag.rb index 22af2a183..6b3113f30 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -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 diff --git a/test/unit/artist_test.rb b/test/unit/artist_test.rb index ba7b75f4b..5d58a64db 100644 --- a/test/unit/artist_test.rb +++ b/test/unit/artist_test.rb @@ -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) diff --git a/test/unit/pool_test.rb b/test/unit/pool_test.rb index 6b544974e..512bbd791 100644 --- a/test/unit/pool_test.rb +++ b/test/unit/pool_test.rb @@ -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 diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 81bd71974..f146dc6b4 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -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")