mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
Fix undefined variable in TopicCreator
.
This commit is contained in:
@ -8,7 +8,15 @@ describe TopicCreator do
|
||||
|
||||
let(:valid_attrs) { Fabricate.attributes_for(:topic) }
|
||||
let(:pm_valid_attrs) { { raw: 'this is a new post', title: 'this is a new title', archetype: Archetype.private_message, target_usernames: moderator.username } }
|
||||
let(:pm_to_email_valid_attrs) { { raw: 'this is a new email', title: 'this is a new subject', archetype: Archetype.private_message, target_emails: 'moderator@example.com' } }
|
||||
|
||||
let(:pm_to_email_valid_attrs) do
|
||||
{
|
||||
raw: 'this is a new email',
|
||||
title: 'this is a new subject',
|
||||
archetype: Archetype.private_message,
|
||||
target_emails: 'moderator@example.com'
|
||||
}
|
||||
end
|
||||
|
||||
describe '#create' do
|
||||
context 'topic success cases' do
|
||||
@ -72,15 +80,25 @@ describe TopicCreator do
|
||||
end
|
||||
|
||||
it "should be possible for a trusted user to send private messages via email" do
|
||||
SiteSetting.expects(:enable_staged_users).returns(true)
|
||||
SiteSetting.expects(:enable_staged_users).returns(true)
|
||||
SiteSetting.expects(:enable_private_email_messages).returns(true)
|
||||
SiteSetting.min_trust_to_send_email_messages = TrustLevel[1]
|
||||
|
||||
expect(TopicCreator.create(user, Guardian.new(user), pm_to_email_valid_attrs)).to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context 'failure cases' do
|
||||
it "should be rollback the changes when email is invalid" do
|
||||
SiteSetting.expects(:enable_private_email_messages).returns(true)
|
||||
SiteSetting.min_trust_to_send_email_messages = TrustLevel[1]
|
||||
attrs = pm_to_email_valid_attrs.dup
|
||||
attrs[:target_emails] = "t" * 256
|
||||
|
||||
expect do
|
||||
TopicCreator.create(user, Guardian.new(user), attrs)
|
||||
end.to raise_error(ActiveRecord::Rollback)
|
||||
end
|
||||
|
||||
it "min_trust_to_send_messages setting should be checked when sending private message" do
|
||||
SiteSetting.min_trust_to_send_messages = TrustLevel[4]
|
||||
|
||||
|
Reference in New Issue
Block a user