improved test

This commit is contained in:
albert
2012-05-11 18:04:50 -04:00
parent 157789d4d5
commit 91ef2a6df2

View File

@@ -7,8 +7,6 @@ class CommentTest < ActiveSupport::TestCase
CurrentUser.user = user CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1" CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all MEMCACHE.flush_all
Danbooru.config.stubs(:member_comment_limit).returns(100)
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
end end
teardown do teardown do
@@ -16,6 +14,25 @@ class CommentTest < ActiveSupport::TestCase
CurrentUser.ip_addr = nil CurrentUser.ip_addr = nil
end end
context "created by a limited user" do
setup do
Danbooru.config.stubs(:member_comment_limit).returns(5)
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.ago)
end
should "fail creation" do
comment = Factory.build(:comment)
comment.save
assert_equal(["Creator can not post comments within 1 week of sign up, and can only post 5 comments per hour after that"], comment.errors.full_messages)
end
end
context "created by an unlimited user" do
setup do
Danbooru.config.stubs(:member_comment_limit).returns(100)
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
end
should "be created" do should "be created" do
comment = Factory.build(:comment) comment = Factory.build(:comment)
comment.save comment.save
@@ -71,3 +88,4 @@ class CommentTest < ActiveSupport::TestCase
end end
end end
end end
end