New Feature: Staff can choose to "Take Action" when flagging to immediately reach hiding

thresholds.
This commit is contained in:
Robin Ward
2013-05-31 17:38:28 -04:00
parent 476ffcc627
commit 545dbfc07e
19 changed files with 194 additions and 135 deletions

View File

@ -9,7 +9,7 @@ describe PostActionsController do
describe 'logged in' do
before do
@user = log_in
@user = log_in(:moderator)
@post = Fabricate(:post, user: Fabricate(:coding_horror))
end
@ -34,9 +34,26 @@ describe PostActionsController do
end
it 'allows us to create an post action on a post' do
PostAction.expects(:act).once.with(@user, @post, PostActionType.types[:like], nil)
PostAction.expects(:act).once.with(@user, @post, PostActionType.types[:like], {})
xhr :post, :create, id: @post.id, post_action_type_id: PostActionType.types[:like]
end
it 'passes the message through' do
PostAction.expects(:act).once.with(@user, @post, PostActionType.types[:like], {message: 'action message goes here'})
xhr :post, :create, id: @post.id, post_action_type_id: PostActionType.types[:like], message: 'action message goes here'
end
it 'passes take_action through' do
PostAction.expects(:act).once.with(@user, @post, PostActionType.types[:like], {take_action: true})
xhr :post, :create, id: @post.id, post_action_type_id: PostActionType.types[:like], take_action: 'true'
end
it "doesn't pass take_action through if the user isn't staff" do
Guardian.any_instance.stubs(:is_staff?).returns(false)
PostAction.expects(:act).once.with(@user, @post, PostActionType.types[:like], {})
xhr :post, :create, id: @post.id, post_action_type_id: PostActionType.types[:like], take_action: 'true'
end
end
end