FEATURE: Can create warnings for users via PM

This commit is contained in:
Robin Ward
2014-09-05 15:40:25 -04:00
parent a8e4c4caa1
commit b0bfc1f93f
37 changed files with 243 additions and 18 deletions

View File

@ -384,6 +384,7 @@ describe PostsController do
describe 'when logged in' do
let!(:user) { log_in }
let(:moderator) { log_in(:moderator) }
let(:new_post) { Fabricate.build(:post, user: user) }
it "raises an exception without a raw parameter" do
@ -492,6 +493,24 @@ describe PostsController do
xhr :post, :create, {raw: 'hello', meta_data: {xyz: 'abc'}}
end
context "is_warning" do
it "doesn't pass `is_warning` through if you're not staff" do
PostCreator.expects(:new).with(user, Not(has_entries('is_warning' => true))).returns(post_creator)
xhr :post, :create, {raw: 'hello', archetype: 'private_message', is_warning: 'true'}
end
it "passes `is_warning` through if you're staff" do
PostCreator.expects(:new).with(moderator, has_entries('is_warning' => true)).returns(post_creator)
xhr :post, :create, {raw: 'hello', archetype: 'private_message', is_warning: 'true'}
end
it "passes `is_warning` as false through if you're staff" do
PostCreator.expects(:new).with(moderator, has_entries('is_warning' => false)).returns(post_creator)
xhr :post, :create, {raw: 'hello', archetype: 'private_message', is_warning: 'false'}
end
end
end
end