2013-02-05 13:16:51 -06:00
|
|
|
require 'spec_helper'
|
2013-10-01 02:04:02 -05:00
|
|
|
require 'jobs/regular/send_system_message'
|
2013-02-05 13:16:51 -06:00
|
|
|
|
|
|
|
describe Jobs::SendSystemMessage do
|
|
|
|
|
|
|
|
it "raises an error without a user_id" do
|
2014-12-31 08:55:03 -06:00
|
|
|
expect { Jobs::SendSystemMessage.new.execute(message_type: 'welcome_invite') }.to raise_error(Discourse::InvalidParameters)
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an error without a message_type" do
|
2014-12-31 08:55:03 -06:00
|
|
|
expect { Jobs::SendSystemMessage.new.execute(user_id: 1234) }.to raise_error(Discourse::InvalidParameters)
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with valid parameters' do
|
|
|
|
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
|
2013-02-25 10:42:20 -06:00
|
|
|
it "should call SystemMessage.create" do
|
2013-02-05 13:16:51 -06:00
|
|
|
SystemMessage.any_instance.expects(:create).with('welcome_invite')
|
2013-02-25 10:42:20 -06:00
|
|
|
Jobs::SendSystemMessage.new.execute(user_id: user.id, message_type: 'welcome_invite')
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|