fixed unit tests, tweaked attr_accessible rules

This commit is contained in:
albert
2010-02-19 17:54:44 -05:00
parent 703eb6a1b6
commit 2f907c67b5
7 changed files with 53 additions and 23 deletions

View File

@@ -27,11 +27,10 @@ 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.update_attributes(
:updater_id => artist.creator_id,
:updater_ip_addr => "127.0.0.1",
:url_string => "http://not.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
assert_equal(["http://not.rembrandt.com/test.jpg"], artist.artist_urls.map(&:to_s).sort)
end
@@ -80,11 +79,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", :creator_id => user.id, :updater_id => user.id, :updater_ip_addr => "127.0.0.1"})
artist = Factory.create(:artist, :name => "max", :wiki_page_attributes => {:body => "this is max", :updater_id => user.id, :updater_ip_addr => "127.0.0.1"})
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", :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, :updater_id => user.id, :updater_ip_addr => "127.0.0.1"})
assert_equal("this is hoge mark ii", artist.wiki_page(true).body)
end
@@ -96,11 +95,10 @@ class ArtistTest < ActiveSupport::TestCase
end
assert_difference("ArtistVersion.count") do
artist.update_attributes(
:updater_id => user.id,
:updater_ip_addr => "127.0.0.1",
:other_names => "xxx"
)
artist.updater_id = user.id
artist.updater_ip_addr = "127.0.0.1"
artist.other_names = "xxx"
artist.save
end
first_version = ArtistVersion.first

View File

@@ -2,13 +2,23 @@ require File.dirname(__FILE__) + '/../test_helper'
class PoolTest < ActiveSupport::TestCase
context "A pool" do
setup do
MEMCACHE.flush_all
end
should "create versions for each distinct user" do
pool = Factory.create(:pool)
user = Factory.create(:user)
assert_equal(1, pool.versions(true).size)
pool.update_attributes(:post_ids => "1", :updater_id => user.id, :updater_ip_addr => "128.0.0.1")
pool.post_ids = "1"
pool.updater_id = user.id
pool.updater_ip_addr = "128.0.0.1"
pool.save
assert_equal(2, pool.versions(true).size)
pool.update_attributes(:post_ids => "1 2", :updater_id => user.id, :updater_ip_addr => "128.0.0.1")
pool.post_ids = "1 2"
pool.updater_id = user.id
pool.updater_ip_addr = "128.0.0.1"
pool.save
assert_equal(2, pool.versions(true).size)
pool.revert_to!(PoolVersion.first)
assert_equal("", pool.post_ids)
@@ -59,7 +69,6 @@ class PoolTest < ActiveSupport::TestCase
user = Factory.create(:user)
pool = Pool.create_anonymous(user, "127.0.0.1")
assert_match(/^anonymous:\d+$/, pool.name)
end
end
end

View File

@@ -27,7 +27,10 @@ class WikiPageTest < ActiveSupport::TestCase
end
assert_difference("WikiPageVersion.count") do
wp.update_attributes(:title => "yyy", :updater_id => user.id, :updater_ip_addr => "127.0.0.1")
wp.title = "yyy"
wp.updater_id = user.id
wp.updater_ip_addr = "127.0.0.1"
wp.save
end
version = WikiPageVersion.first