* Added note version controller and test
* Added pool version controller and test * Refactored unit tests for post disapprovals * Renamed PostModerationDetail to PostDisapproval
This commit is contained in:
@@ -1,37 +1,51 @@
|
||||
require "test_helper"
|
||||
|
||||
class PostModerationControllerTest < ActionController::TestCase
|
||||
context "A post moderation controller" do
|
||||
should "" do
|
||||
ModQueuePost.destroy_all
|
||||
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
|
||||
|
||||
p1 = create_post("hoge", :status => "pending")
|
||||
p2 = create_post("hoge", :status => "active")
|
||||
p3 = create_post("moge", :status => "active")
|
||||
|
||||
p2.flag!("sage", User.find(1))
|
||||
p2.reload
|
||||
assert_not_nil(p2.flag_detail)
|
||||
|
||||
get :moderate, {}, {:user_id => 1}
|
||||
assert_response :success
|
||||
|
||||
get :moderate, {:query => "moge"}, {:user_id => 1}
|
||||
assert_response :success
|
||||
|
||||
post :moderate, {:id => p1.id, :commit => "Approve"}, {:user_id => 1}
|
||||
p1.reload
|
||||
assert_equal("active", p1.status)
|
||||
|
||||
post :moderate, {:id => p3.id, :reason => "sage", :commit => "Delete"}, {:user_id => 1}
|
||||
p3.reload
|
||||
assert_equal("deleted", p3.status)
|
||||
assert_not_nil(p3.flag_detail)
|
||||
assert_equal("sage", p3.flag_detail.reason)
|
||||
|
||||
assert_equal(0, ModQueuePost.count)
|
||||
post :moderate, {:id => "3", :commit => "Hide"}, {:user_id => 1}
|
||||
assert_equal(1, ModQueuePost.count)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user