Files
danbooru/test/functional/post_moderation_controller_test.rb
albert 683d4583ac * Added note version controller and test
* Added pool version controller and test
* Refactored unit tests for post disapprovals
* Renamed PostModerationDetail to PostDisapproval
2011-01-25 18:13:05 -05:00

52 lines
1.2 KiB
Ruby

require "test_helper"
class PostModerationControllerTest < ActionController::TestCase
context "The post moderation controller" do
setup do
@mod = Factory.create(:moderator_user)
CurrentUser.user = @mod
CurrentUser.ip_addr = "127.0.0.1"
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "moderate action" do
setup do
@post = Factory.create(:post, :is_pending => true)
end
should "list all pending posts" do
get :moderate, {}, {:user_id => @mod.id}
assert_response :success
end
end
context "approve action" do
setup do
@post = Factory.create(:post, :is_pending => true)
end
should "approve a post" do
post :approve, {:post_id => @post.id}, {:user_id => @mod.id}
@post.reload
assert(!@post.is_pending?)
end
end
context "disapprove action" do
setup do
@post = Factory.create(:post, :is_pending => true)
end
should "disapprove a post" do
assert_difference("PostDisapproval.count", 1) do
post :disapprove, {:post_id => @post.id}, {:user_id => @mod.id}
end
end
end
end
end