fixed tests
This commit is contained in:
@@ -4,11 +4,18 @@ class DmailTest < ActiveSupport::TestCase
|
||||
context "A dmail" do
|
||||
setup do
|
||||
MEMCACHE.flush_all
|
||||
@user = Factory.create(:user)
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
ActionMailer::Base.delivery_method = :test
|
||||
ActionMailer::Base.perform_deliveries = true
|
||||
ActionMailer::Base.deliveries = []
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
end
|
||||
|
||||
context "search" do
|
||||
should "return results based on title contents" do
|
||||
dmail = Factory.create(:dmail, :title => "xxx")
|
||||
@@ -28,11 +35,10 @@ class DmailTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "should parse user names" do
|
||||
user = Factory.create(:user)
|
||||
dmail = Factory.build(:dmail)
|
||||
dmail.to_id = nil
|
||||
dmail.to_name = user.name
|
||||
assert(dmail.to_id == user.id)
|
||||
dmail.to_name = @user.name
|
||||
assert(dmail.to_id == @user.id)
|
||||
end
|
||||
|
||||
should "construct a response" do
|
||||
@@ -45,9 +51,8 @@ class DmailTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "create a copy for each user" do
|
||||
dmail = Factory.build(:dmail)
|
||||
assert_difference("Dmail.count", 2) do
|
||||
Dmail.create_split(dmail.attributes)
|
||||
Dmail.create_split(:to_id => @user.id, :title => "foo", :body => "foo")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ class FavoriteTest < ActiveSupport::TestCase
|
||||
p1.add_favorite(user1)
|
||||
p2.add_favorite(user1)
|
||||
p3.add_favorite(user1)
|
||||
favorites = user1.favorite_posts(:limit => 1)
|
||||
favorites = user1.favorite_posts(:before => favorites.first.favorite_id)
|
||||
assert_equal(2, favorites.size)
|
||||
favorites = user1.favorite_posts
|
||||
favorites = user1.favorite_posts(:before_id => favorites.first.favorite_id)
|
||||
assert_equal(2, favorites.count)
|
||||
assert_equal(p2.id, favorites[0].id)
|
||||
assert_equal(p1.id, favorites[1].id)
|
||||
end
|
||||
|
||||
@@ -68,7 +68,7 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
ta1 = Factory.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "xxx")
|
||||
p1.reload
|
||||
assert_not_equal("uploader:#{ta1.creator_id}", p1.uploader_string)
|
||||
assert_equal(ta1.creator_id, p1.versions.last.updater_id)
|
||||
assert_equal(ta1.creator_id, p1.history.revisions.last["user_id"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -114,7 +114,7 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
ti1 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "xxx")
|
||||
p1.reload
|
||||
assert_not_equal("uploader:#{ti1.creator_id}", p1.uploader_string)
|
||||
assert_equal(ti1.creator_id, p1.versions.last.updater_id)
|
||||
assert_equal(ti1.creator_id, p1.history.revisions.last["user_id"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user