fixed tests

This commit is contained in:
albert
2011-10-16 01:40:42 -04:00
parent d2f2203c33
commit a7267cf00b
12 changed files with 141 additions and 30 deletions

View File

@@ -28,7 +28,7 @@ class PostAppealTest < ActiveSupport::TestCase
@post_appeal = PostAppeal.create(:post => @post, :reason => "aaa")
end
assert_equal(["Creator has already appealed this post"], @post_appeal.errors.full_messages)
assert_equal(["You have already appealed this post"], @post_appeal.errors.full_messages)
end
should "not be able to appeal more than 5 posts in 24 hours" do
@@ -37,7 +37,7 @@ class PostAppealTest < ActiveSupport::TestCase
assert_difference("PostAppeal.count", 0) do
@post_appeal.save
end
assert_equal(["Creator can appeal 5 posts a day"], @post_appeal.errors.full_messages)
assert_equal(["You can appeal 5 posts a day"], @post_appeal.errors.full_messages)
end
should "not be able to appeal an active post" do

View File

@@ -28,7 +28,7 @@ class PostFlagTest < ActiveSupport::TestCase
@post_flag = PostFlag.create(:post => @post, :reason => "aaa")
end
assert_equal(["Creator has already flagged this post"], @post_flag.errors.full_messages)
assert_equal(["You have already flagged this post"], @post_flag.errors.full_messages)
end
should "not be able to flag more than 10 posts in 24 hours" do
@@ -37,7 +37,7 @@ class PostFlagTest < ActiveSupport::TestCase
assert_difference("PostFlag.count", 0) do
@post_flag.save
end
assert_equal(["Creator can flag 10 posts a day"], @post_flag.errors.full_messages)
assert_equal(["You can flag 10 posts a day"], @post_flag.errors.full_messages)
end
should "not be able to flag a deleted post" do

View File

@@ -14,6 +14,17 @@ class PostTest < ActiveSupport::TestCase
end
context "Deletion:" do
context "Annihilating a post" do
setup do
@post = Factory.create(:post)
@post.annihilate!
end
should "destroy the record" do
assert_equal(0, Post.where("id = ?", @post.id).count)
end
end
context "Deleting a post" do
should "update the fast count" do
post = Factory.create(:post, :tag_string => "aaa")

View File

@@ -45,7 +45,7 @@ class TagAliasTest < ActiveSupport::TestCase
ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "ccc")
post1.reload
post2.reload
assert_equal("ccc bbb", post1.tag_string)
assert_equal("bbb ccc", post1.tag_string)
assert_equal("ccc ddd", post2.tag_string)
end

View File

@@ -80,7 +80,7 @@ class TagImplicationTest < ActiveSupport::TestCase
ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "xxx")
ti2 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "yyy")
p1.reload
assert_equal("aaa yyy xxx bbb ccc", p1.tag_string)
assert_equal("aaa bbb ccc xxx yyy", p1.tag_string)
end
should "record the implication's creator in the tag history" do

View File

@@ -106,7 +106,7 @@ class TagTest < ActiveSupport::TestCase
should "strip out invalid characters when scanning" do
assert_equal(%w(aaa bbb), Tag.scan_tags("aaa bbb"))
assert_equal(%w(-b_b_b_), Tag.scan_tags("-B,B;B* -b_b_b_"))
assert_equal(%w(-bb;b* -b_b_b_), Tag.scan_tags("-B,B;B* -b_b_b_"))
end
should "cast values" do

View File

@@ -140,7 +140,7 @@ class UploadTest < ActiveSupport::TestCase
end
post = Post.last
assert_equal("hoge foo", post.tag_string)
assert_equal("foo hoge", post.tag_string)
assert_equal("s", post.rating)
assert_equal(@upload.uploader_id, post.uploader_id)
assert_equal("127.0.0.1", post.uploader_ip_addr)
@@ -167,7 +167,7 @@ class UploadTest < ActiveSupport::TestCase
assert_nothing_raised {@upload.process!}
end
post = Post.last
assert_equal("hoge foo", post.tag_string)
assert_equal("foo hoge", post.tag_string)
assert_equal("s", post.rating)
assert_equal(@upload.uploader_id, post.uploader_id)
assert_equal("127.0.0.1", post.uploader_ip_addr)

View File

@@ -54,6 +54,7 @@ class UserTest < ActiveSupport::TestCase
end
should "limit comment votes" do
Danbooru.config.stubs(:member_comment_limit).returns(10)
assert(@user.can_comment_vote?)
10.times do
comment = Factory.create(:comment)
@@ -176,7 +177,7 @@ class UserTest < ActiveSupport::TestCase
context "cookie password hash" do
setup do
@user = Factory.create(:user, :password_hash => "1234")
@user = Factory.create(:user, :name => "albert", :password_hash => "1234")
end
should "be correct" do