Sha256: 787089239e003742bda461f8f3c5edcf796e6bbd8b46fb4287551972a116abf8

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe Locomotive::Steam::AsyncEmailService do

  let(:page_finder)   { instance_double('PageFinder') }
  let(:liquid_parser) { instance_double('LiquidParser') }
  let(:asset_host)    { instance_double('AssetHost') }
  let(:simulation)    { false }
  let(:service)       { described_class.new(page_finder, liquid_parser, asset_host, simulation) }

  describe '#send_email!' do

    let(:options) { { to: 'john@doe.net', attachments: { 'foo.png' => 'Hello world' }, via: :smtp, via_options: { address: 'smtp.mydomain.org', authentication: :plain } } }

    subject { service.send_email!(options) }

    it 'creates a new job' do
      expect(Locomotive::SendPonyEmailJob).to receive(:perform_later).with({
        'to'  => 'john@doe.net',
        'attachments' => { 'foo.png' => "SGVsbG8gd29ybGQ=\n" },
        'via' => 'smtp',
        'via_options' => {
          'address' => 'smtp.mydomain.org',
          'authentication' => 'plain'
        }
      })
      subject
    end

    context 'no via options' do

      let(:options) { { to: 'john@doe.net' } }

      it 'creates a new job' do
        expect(Locomotive::SendPonyEmailJob).to receive(:perform_later).with({
          'to'  => 'john@doe.net'
        })
        subject
      end

    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locomotivecms-3.3.0 spec/lib/locomotive/steam/services/async_email_service_spec.rb
locomotivecms-3.3.0.rc3 spec/lib/locomotive/steam/services/async_email_service_spec.rb
locomotivecms-3.3.0.rc2 spec/lib/locomotive/steam/services/async_email_service_spec.rb
locomotivecms-3.2.1 spec/lib/locomotive/steam/services/async_email_service_spec.rb
locomotivecms-3.3.0.rc1 spec/lib/locomotive/steam/services/async_email_service_spec.rb
locomotivecms-3.2.0 spec/lib/locomotive/steam/services/async_email_service_spec.rb
locomotivecms-3.2.0.rc2 spec/lib/locomotive/steam/services/async_email_service_spec.rb
locomotivecms-3.2.0.rc1 spec/lib/locomotive/steam/services/async_email_service_spec.rb