sync
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
Factory.define(:artist) do |f|
|
||||
f.name {Faker::Name.first_name}
|
||||
f.creator {|x| x.association(:user)}
|
||||
f.updater_id {|x| x.creator_id}
|
||||
f.updater_ip_addr "127.0.0.1"
|
||||
f.is_active true
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
Factory.define(:tag_alias) do |f|
|
||||
f.creator {|x| x.association(:user)}
|
||||
f.updater_id {|x| x.creator_id}
|
||||
f.updater_ip_addr "127.0.0.1"
|
||||
f.creator_ip_addr "127.0.0.1"
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
Factory.define(:tag_implication) do |f|
|
||||
f.creator {|x| x.association(:user)}
|
||||
f.updater_id {|x| x.creator_id}
|
||||
f.updater_ip_addr "127.0.0.1"
|
||||
f.creator_ip_addr "127.0.0.1"
|
||||
end
|
||||
|
||||
@@ -3,8 +3,34 @@ require_relative '../test_helper'
|
||||
class ArtistTest < ActiveSupport::TestCase
|
||||
context "An artist" do
|
||||
setup do
|
||||
user = Factory.create(:user)
|
||||
CurrentUser.user = user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
MEMCACHE.flush_all
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
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")
|
||||
end
|
||||
assert_equal("testing", artist.notes)
|
||||
assert_equal("testing", artist.wiki_page.body)
|
||||
assert_equal(artist.name, artist.wiki_page.title)
|
||||
end
|
||||
|
||||
should "update the wiki page when notes are assigned" do
|
||||
artist = Factory.create(:artist, :name => "aaa", :notes => "testing")
|
||||
artist.update_attribute(:notes, "kokoko")
|
||||
artist.reload
|
||||
assert_equal("kokoko", artist.notes)
|
||||
assert_equal("kokoko", artist.wiki_page.body)
|
||||
end
|
||||
|
||||
should "normalize its name" do
|
||||
artist = Factory.create(:artist, :name => " AAA BBB ")
|
||||
@@ -27,8 +53,6 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
|
||||
should "make sure old urls are deleted" do
|
||||
artist = Factory.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg")
|
||||
artist.updater_id = artist.creator_id
|
||||
artist.updater_ip_addr = "127.0.0.1"
|
||||
artist.url_string = "http://not.rembrandt.com/test.jpg"
|
||||
artist.save
|
||||
artist.reload
|
||||
@@ -79,11 +103,11 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
|
||||
should "have an associated wiki" do
|
||||
user = Factory.create(:user)
|
||||
artist = Factory.create(:artist, :name => "max", :wiki_page_attributes => {:body => "this is max", :updater_id => user.id, :updater_ip_addr => "127.0.0.1"})
|
||||
artist = Factory.create(:artist, :name => "max", :wiki_page_attributes => {:body => "this is max"})
|
||||
assert_not_nil(artist.wiki_page)
|
||||
assert_equal("this is max", artist.wiki_page.body)
|
||||
|
||||
artist.update_attributes(:wiki_page_attributes => {:id => artist.wiki_page.id, :body => "this is hoge mark ii", :creator_id => user.id, :updater_id => user.id, :updater_ip_addr => "127.0.0.1"})
|
||||
artist.update_attributes(:wiki_page_attributes => {:id => artist.wiki_page.id, :body => "this is hoge mark ii", :creator_id => user.id})
|
||||
assert_equal("this is hoge mark ii", artist.wiki_page(true).body)
|
||||
end
|
||||
|
||||
@@ -96,15 +120,13 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
assert_difference("ArtistVersion.count") do
|
||||
artist.updater_id = user.id
|
||||
artist.updater_ip_addr = "127.0.0.1"
|
||||
artist.other_names = "xxx"
|
||||
artist.save
|
||||
end
|
||||
|
||||
first_version = ArtistVersion.first
|
||||
assert_equal("yyy", first_version.other_names)
|
||||
artist.revert_to!(first_version, reverter.id, "127.0.0.1")
|
||||
artist.revert_to!(first_version)
|
||||
artist.reload
|
||||
assert_equal("yyy", artist.other_names)
|
||||
end
|
||||
|
||||
@@ -36,9 +36,7 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
assert_equal(["bbb"], ti1.descendant_names_array)
|
||||
assert_equal(["bbb"], MEMCACHE.get("ti:aaa"))
|
||||
ti1.update_attributes(
|
||||
:consequent_name => "ccc",
|
||||
:updater_id => @user.id,
|
||||
:updater_ip_addr => "127.0.0.1"
|
||||
:consequent_name => "ccc"
|
||||
)
|
||||
assert_nil(MEMCACHE.get("ti:aaa"))
|
||||
end
|
||||
@@ -71,9 +69,7 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
ti1 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||
ti2 = Factory.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd")
|
||||
ti2.update_attributes(
|
||||
:antecedent_name => "bbb",
|
||||
:updater_id => @user.id,
|
||||
:updater_ip_addr => "127.0.0.1"
|
||||
:antecedent_name => "bbb"
|
||||
)
|
||||
ti1.reload
|
||||
ti2.reload
|
||||
|
||||
Reference in New Issue
Block a user