Sha256: 7b720b42eac32abc47df212e10399fa0780fd7773576f42c0c8b7617e48f7f5c

Contents?: true

Size: 1.54 KB

Versions: 10

Compression:

Stored size: 1.54 KB

Contents

# encoding: UTF-8
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper')

class AuMailInterceptorMailer < ActionMailer::Base
  include ActionView::Helpers::TagHelper
  include ActionView::Helpers::AssetTagHelper

  def ticket(mail_address)
    attachments.inline['ticket-qr-code.gif'] = "blob"
    mail(:from => "info@mobalean.com",
         :to => mail_address,
         :subject => "subjectline") do |format|
      format.text { render :text => "HELLO world" }
      format.html do
        render :inline => image_tag(attachments['ticket-qr-code.gif'].url,
                                    :alt => 'QR-code ticket')
      end
    end
  end

  def controller
    self
  end
end

describe 'email' do
  let(:email){ ActionMailer::Base.deliveries.last }
  before { AuMailInterceptorMailer.ticket(mail_address).deliver }

  context "RFC compliant multipart mail" do
    let(:mail_address) { "info@mobalean.com" }
    it { email.content_type.should match /^multipart\/related/ }
    it { email.content_type_parameters.should include("boundary") }
    it { email.parts.size.should == 2 }
    it { email.parts.map(&:mime_type).sort.should == ["image/gif", "multipart/alternative"] }
  end

  context "au html multipart mail" do
    let(:mail_address) { "hihihi@ezweb.ne.jp" }
    it { email.content_type.should match /^multipart\/alternative/ }
    it { email.content_type_parameters.should include("boundary") }
    it { email.parts.size.should == 3 }
    it { email.parts.map(&:mime_type).sort.should == ["image/gif", "text/html", "text/plain" ] }
 end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
galakei-0.13.7 spec/acceptance/au_mail_interceptor_spec.rb
galakei-0.13.6 spec/acceptance/au_mail_interceptor_spec.rb
galakei-0.13.5 spec/acceptance/au_mail_interceptor_spec.rb
galakei-0.13.4 spec/acceptance/au_mail_interceptor_spec.rb
galakei-0.13.3 spec/acceptance/au_mail_interceptor_spec.rb
galakei-0.13.2 spec/acceptance/au_mail_interceptor_spec.rb
galakei-0.13.1 spec/acceptance/au_mail_interceptor_spec.rb
galakei-0.13.0 spec/acceptance/au_mail_interceptor_spec.rb
galakei-0.12.1 spec/acceptance/au_mail_interceptor_spec.rb
galakei-0.12.0 spec/acceptance/au_mail_interceptor_spec.rb