* Removed Pixa/Tinami sources
* Upgraded to Rails 3.2.3 * Fixed tests
This commit is contained in:
@@ -3,7 +3,7 @@ require 'test_helper'
|
||||
class ArtistTest < ActiveSupport::TestCase
|
||||
context "An artist" do
|
||||
setup do
|
||||
user = Factory.create(:user)
|
||||
user = FactoryGirl.create(:user)
|
||||
CurrentUser.user = user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
MEMCACHE.flush_all
|
||||
@@ -16,8 +16,8 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
|
||||
context "with a matching tag alias" do
|
||||
setup do
|
||||
@tag_alias = Factory.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||
@artist = Factory.create(:artist, :name => "aaa")
|
||||
@tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||
@artist = FactoryGirl.create(:artist, :name => "aaa")
|
||||
end
|
||||
|
||||
should "know it has an alias" do
|
||||
@@ -31,8 +31,8 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
|
||||
context "that has been banned" do
|
||||
setup do
|
||||
@post = Factory.create(:post, :tag_string => "aaa")
|
||||
@artist = Factory.create(:artist, :name => "aaa")
|
||||
@post = FactoryGirl.create(:post, :tag_string => "aaa")
|
||||
@artist = FactoryGirl.create(:artist, :name => "aaa")
|
||||
@artist.update_attributes({:is_banned => true}, :as => :admin)
|
||||
@post.reload
|
||||
end
|
||||
@@ -49,7 +49,7 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
should "create a new wiki page to store any note information" do
|
||||
artist = nil
|
||||
assert_difference("WikiPage.count") do
|
||||
artist = Factory.create(:artist, :name => "aaa", :notes => "testing")
|
||||
artist = FactoryGirl.create(:artist, :name => "aaa", :notes => "testing")
|
||||
end
|
||||
assert_equal("testing", artist.notes)
|
||||
assert_equal("testing", artist.wiki_page.body)
|
||||
@@ -57,7 +57,7 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "update the wiki page when notes are assigned" do
|
||||
artist = Factory.create(:artist, :name => "aaa", :notes => "testing")
|
||||
artist = FactoryGirl.create(:artist, :name => "aaa", :notes => "testing")
|
||||
artist.update_attribute(:notes, "kokoko")
|
||||
artist.reload
|
||||
assert_equal("kokoko", artist.notes)
|
||||
@@ -65,26 +65,26 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "normalize its name" do
|
||||
artist = Factory.create(:artist, :name => " AAA BBB ")
|
||||
artist = FactoryGirl.create(:artist, :name => " AAA BBB ")
|
||||
assert_equal("aaa_bbb", artist.name)
|
||||
end
|
||||
|
||||
should "resolve ambiguous urls" do
|
||||
bobross = Factory.create(:artist, :name => "bob_ross", :url_string => "http://artists.com/bobross/image.jpg")
|
||||
bob = Factory.create(:artist, :name => "bob", :url_string => "http://artists.com/bob/image.jpg")
|
||||
bobross = FactoryGirl.create(:artist, :name => "bob_ross", :url_string => "http://artists.com/bobross/image.jpg")
|
||||
bob = FactoryGirl.create(:artist, :name => "bob", :url_string => "http://artists.com/bob/image.jpg")
|
||||
matches = Artist.find_all_by_url("http://artists.com/bob/test.jpg")
|
||||
assert_equal(1, matches.size)
|
||||
assert_equal("bob", matches.first.name)
|
||||
end
|
||||
|
||||
should "parse urls" do
|
||||
artist = Factory.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg http://aaa.com")
|
||||
artist = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg http://aaa.com")
|
||||
artist.reload
|
||||
assert_equal(["http://aaa.com", "http://rembrandt.com/test.jpg"], artist.urls.map(&:to_s).sort)
|
||||
end
|
||||
|
||||
should "make sure old urls are deleted" do
|
||||
artist = Factory.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg")
|
||||
artist = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg")
|
||||
artist.url_string = "http://not.rembrandt.com/test.jpg"
|
||||
artist.save
|
||||
artist.reload
|
||||
@@ -92,8 +92,8 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "find matches by url" do
|
||||
a1 = Factory.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg")
|
||||
a2 = Factory.create(:artist, :name => "subway", :url_string => "http://subway.com/test.jpg")
|
||||
a1 = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg")
|
||||
a2 = FactoryGirl.create(:artist, :name => "subway", :url_string => "http://subway.com/test.jpg")
|
||||
|
||||
assert_equal(["rembrandt"], Artist.find_all_by_url("http://rembrandt.com/test.jpg").map(&:name))
|
||||
assert_equal(["rembrandt"], Artist.find_all_by_url("http://rembrandt.com/another.jpg").map(&:name))
|
||||
@@ -101,39 +101,39 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "not allow duplicates" do
|
||||
Factory.create(:artist, :name => "warhol", :url_string => "http://warhol.com/a/image.jpg\nhttp://warhol.com/b/image.jpg")
|
||||
FactoryGirl.create(:artist, :name => "warhol", :url_string => "http://warhol.com/a/image.jpg\nhttp://warhol.com/b/image.jpg")
|
||||
assert_equal(["warhol"], Artist.find_all_by_url("http://warhol.com/test.jpg").map(&:name))
|
||||
end
|
||||
|
||||
should "hide deleted artists" do
|
||||
Factory.create(:artist, :name => "warhol", :url_string => "http://warhol.com/a/image.jpg", :is_active => false)
|
||||
FactoryGirl.create(:artist, :name => "warhol", :url_string => "http://warhol.com/a/image.jpg", :is_active => false)
|
||||
assert_equal([], Artist.find_all_by_url("http://warhol.com/a/image.jpg").map(&:name))
|
||||
end
|
||||
|
||||
should "normalize its other names" do
|
||||
artist = Factory.create(:artist, :name => "a1", :other_names => "aaa, bbb, ccc ddd")
|
||||
artist = FactoryGirl.create(:artist, :name => "a1", :other_names => "aaa, bbb, ccc ddd")
|
||||
assert_equal("aaa bbb ccc_ddd", artist.other_names)
|
||||
end
|
||||
|
||||
should "search on other names should return matches" do
|
||||
artist = Factory.create(:artist, :name => "artist", :other_names => "aaa, ccc ddd")
|
||||
artist = FactoryGirl.create(:artist, :name => "artist", :other_names => "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)
|
||||
end
|
||||
|
||||
should "search on group name and return matches" do
|
||||
cat_or_fish = Factory.create(:artist, :name => "cat_or_fish")
|
||||
yuu = Factory.create(:artist, :name => "yuu", :group_name => "cat_or_fish")
|
||||
cat_or_fish = FactoryGirl.create(:artist, :name => "cat_or_fish")
|
||||
yuu = FactoryGirl.create(:artist, :name => "yuu", :group_name => "cat_or_fish")
|
||||
cat_or_fish.reload
|
||||
assert_equal("yuu", cat_or_fish.member_names)
|
||||
assert_not_nil(Artist.search(:group_name_contains => "cat_or_fish").first)
|
||||
end
|
||||
|
||||
should "have an associated wiki" do
|
||||
user = Factory.create(:user)
|
||||
user = FactoryGirl.create(:user)
|
||||
CurrentUser.user = user
|
||||
artist = Factory.create(:artist, :name => "max", :wiki_page_attributes => {:title => "xxx", :body => "this is max"})
|
||||
artist = FactoryGirl.create(:artist, :name => "max", :wiki_page_attributes => {:title => "xxx", :body => "this is max"})
|
||||
assert_not_nil(artist.wiki_page)
|
||||
assert_equal("this is max", artist.wiki_page.body)
|
||||
|
||||
@@ -143,11 +143,11 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "revert to prior versions" do
|
||||
user = Factory.create(:user)
|
||||
reverter = Factory.create(:user)
|
||||
user = FactoryGirl.create(:user)
|
||||
reverter = FactoryGirl.create(:user)
|
||||
artist = nil
|
||||
assert_difference("ArtistVersion.count") do
|
||||
artist = Factory.create(:artist, :other_names => "yyy")
|
||||
artist = FactoryGirl.create(:artist, :other_names => "yyy")
|
||||
end
|
||||
|
||||
assert_difference("ArtistVersion.count") do
|
||||
|
||||
Reference in New Issue
Block a user