Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notifier role to miq_server so email task gets queued #25

Merged
merged 2 commits into from
May 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 33 additions & 22 deletions spec/engine/miq_ae_method_service/miq_ae_service_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,44 @@ def invoke_ae
end
end

it "#send_mail" do
options = {
:to => "[email protected]",
:from => "[email protected]",
:body => "What are we having for dinner?",
:content_type => "text/fred",
:subject => "Dinner"
}

method = "$evm.root['#{@ae_result_key}'] = $evm.execute(:send_email, #{options[:to].inspect}, #{options[:from].inspect}, #{options[:subject].inspect}, #{options[:body].inspect}, #{options[:content_type].inspect})"
@ae_method.update_attributes(:data => method)
stub_const('MiqAeMethodService::MiqAeServiceMethods::SYNCHRONOUS', true)
expect(GenericMailer).to receive(:deliver).with(:automation_notification, options).once
ae_object = invoke_ae.root(@ae_result_key)
expect(ae_object).to be_truthy
context "#send_mail" do
let(:options) do
{
:to => "[email protected]",
:from => "[email protected]",
:body => "What are we having for dinner?",
:content_type => "text/fred",
:subject => "Dinner"
}
end

method = "$evm.root['#{@ae_result_key}'] = $evm.execute(:send_email, #{options[:to].inspect}, #{options[:from].inspect}, #{options[:subject].inspect}, #{options[:body].inspect}, #{options[:content_type].inspect})"
@ae_method.update_attributes(:data => method)
stub_const('MiqAeMethodService::MiqAeServiceMethods::SYNCHRONOUS', false)
expect(MiqQueue).to receive(:put).with(
it "sends mail synchronous" do
method = "$evm.root['#{@ae_result_key}'] = $evm.execute(:send_email, #{options[:to].inspect}, #{options[:from].inspect}, #{options[:subject].inspect}, #{options[:body].inspect}, #{options[:content_type].inspect})"
@ae_method.update_attributes(:data => method)
stub_const('MiqAeMethodService::MiqAeServiceMethods::SYNCHRONOUS', true)
expect(GenericMailer).to receive(:deliver).with(:automation_notification, options).once
ae_object = invoke_ae.root(@ae_result_key)
expect(ae_object).to be_truthy
end

it "sends mail asynchronous" do
miq_server = EvmSpecHelper.local_miq_server
MiqRegion.seed
miq_server.server_roles << FactoryGirl.create(:server_role, :name => 'notifier')

method = "$evm.root['#{@ae_result_key}'] = $evm.execute(:send_email, #{options[:to].inspect}, #{options[:from].inspect}, #{options[:subject].inspect}, #{options[:body].inspect}, #{options[:content_type].inspect})"
@ae_method.update_attributes(:data => method)
stub_const('MiqAeMethodService::MiqAeServiceMethods::SYNCHRONOUS', false)
expect(MiqQueue).to receive(:put).with(
:class_name => 'GenericMailer',
:method_name => "deliver",
:args => [:automation_notification, options],
:role => "notifier",
:zone => nil).once
ae_object = invoke_ae.root(@ae_result_key)
expect(ae_object).to be_truthy
:zone => nil
).once
ae_object = invoke_ae.root(@ae_result_key)
expect(ae_object).to be_truthy
end
end

it "#snmp_trap_v1" do
Expand Down