features/steps/notifications_steps.rb in flapjack-0.6.39 vs features/steps/notifications_steps.rb in flapjack-0.6.40
- old
+ new
@@ -1,9 +1,10 @@
include Mail::Matchers
# copied from flapjack-populator
+# TODO use Flapjack::Data::Contact.add
def add_contact(contact = {})
@redis.multi
@redis.del("contact:#{contact['id']}")
@redis.del("contact_media:#{contact['id']}")
@redis.hset("contact:#{contact['id']}", 'first_name', contact['first_name'])
@@ -65,11 +66,11 @@
'state' => 'critical',
'summary' => '100% packet loss',
'entity' => entity,
'check' => 'ping')
entity_check = Flapjack::Data::EntityCheck.for_entity_name(entity, 'ping', :redis => @redis)
- @app.send(:generate_notification, event, entity_check)
+ @app.send(:send_notification_messages, event, entity_check)
end
Then /^an SMS notification for entity '([\w\.\-]+)' should be queued for the user$/ do |entity|
queue = ResqueSpec.peek('sms_notifications')
queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }.should_not be_empty
@@ -125,11 +126,11 @@
# TODO may need to get more complex, depending which SMS provider is used
When /^the SMS notification handler runs successfully$/ do
# returns success by default - currently matches all addresses, maybe load from config?
stub_request(:get, /.*/)
# TODO load config from cfg file instead?
- Flapjack::Notification::Sms.class_variable_set('@@config', {'username' => 'abcd', 'password' => 'efgh'})
+ Flapjack::Notification::Sms.instance_variable_set('@config', {'username' => 'abcd', 'password' => 'efgh'})
lambda {
Flapjack::Notification::Sms.dispatch(@sms_notification, :logger => @logger, :redis => @redis)
}.should_not raise_error
@sms_sent = true
@@ -143,22 +144,24 @@
}.should raise_error
@sms_sent = false
end
When /^the email notification handler runs successfully$/ do
+ Resque.redis = @redis
+ Flapjack::Notification::Email.bootstrap(:config => {})
lambda {
- Flapjack::Notification::Email.dispatch(@email_notification, :logger => @logger, :redis => @redis)
+ Flapjack::Notification::Email.perform(@email_notification)
}.should_not raise_error
end
# This doesn't work as I have it here -- sends a mail with an empty To: header instead.
# Might have to introduce Rspec's stubs here to fake bad mailer behaviour -- or if mail sending
# won't ever fail, don't test for failure?
When /^the email notification handler fails to send an email$/ do
pending
lambda {
@email_notification['address'] = nil
- Flapjack::Notification::Email.dispatch(@email_notification, :logger => @logger, :redis => @redis)
+ Flapjack::Notification::Email.perform(@email_notification)
}.should_not raise_error
end
Then /^the user should receive an SMS notification$/ do
@sms_sent.should be_true