Sha256: 4fbc11b39ba3764b70e03958da6d971040072e74bf28905a699be09dae68c629

Contents?: true

Size: 1.67 KB

Versions: 9

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'
require 'flapjack/gateways/email'

describe Flapjack::Gateways::Email, :logger => true do

  before(:each) do
    Flapjack::Gateways::Email.instance_variable_set('@config', {})
    Flapjack::Gateways::Email.instance_variable_set('@logger', @logger)
    Flapjack::Gateways::Email.start
  end

  it "sends a mail with text and html parts" do
    email = mock('email')

    entity_check = mock(Flapjack::Data::EntityCheck)
    entity_check.should_receive(:in_scheduled_maintenance?).and_return(false)
    entity_check.should_receive(:in_unscheduled_maintenance?).and_return(false)

    redis = mock('redis')
    ::Resque.should_receive(:redis).and_return(redis)

    Flapjack::Data::EntityCheck.should_receive(:for_event_id).
      with('example.com:ping', :redis => redis).and_return(entity_check)

    # TODO better checking of what gets passed here
    EM::P::SmtpClient.should_receive(:send).with(
      hash_including(:host    => 'localhost',
                     :port    => 25)).and_return(email)

    response = mock(response)
    response.should_receive(:"respond_to?").with(:code).and_return(true)
    response.should_receive(:code).and_return(250)

    EM::Synchrony.should_receive(:sync).with(email).and_return(response)

    notification = {'notification_type'   => 'recovery',
                    'contact_first_name'  => 'John',
                    'contact_last_name'   => 'Smith',
                    'state'               => 'ok',
                    'summary'             => 'smile',
                    'time'                => Time.now.to_i,
                    'event_id'            => 'example.com:ping'}

    Flapjack::Gateways::Email.perform(notification)
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
flapjack-0.7.14 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.13 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.12 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.11 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.10 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.9 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.8 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.7 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.6 spec/lib/flapjack/gateways/email_spec.rb