Sha256: 044a96ffcd48ee960b2d669fec6551b269d832ec8061bbd278f4467a1392b76c

Contents?: true

Size: 1.4 KB

Versions: 14

Compression:

Stored size: 1.4 KB

Contents

require 'rails_helper'

class DummyMailer < ApplicationMailer
  def test_mail
    mail(to: 'fake@mail.com') do |format|
      format.html { render inline: erb_template } # rubocop:disable Rails/RenderInline
    end
  end

  private

  def erb_template
    <<-ERB
      <%= root_url %>
    ERB
  end
end

describe PgEngine::BaseMailer do
  describe 'default_url_options' do
    subject do
      mail.deliver
    end

    let(:mail) { DummyMailer.test_mail }

    # rubocop:disable Style/GlobalVars
    before do
      $site_brand_before = PgEngine.site_brand
      PgEngine.site_brand = PgEngine::Test::DummyBrand.new(include_all: true)
    end

    after do
      PgEngine.site_brand = $site_brand_before
    end
    # rubocop:enable Style/GlobalVars

    it 'cuando elige el default' do
      expect { subject }.to have_warned('Default site brand chosen')
      expect(mail.body.encoded).to include 'factura.localhost'
      expect(mail.header_fields.get_field(:from).value).to include 'Factura Bien'
      expect(mail.header_fields.get_field(:from).value).to include 'noreply@factura'
    end

    it 'cuando es un brand especĂ­fico' do
      Current.app_name = :procura
      subject
      expect(mail.body.encoded).to include 'procura.localhost'
      expect(mail.header_fields.get_field(:from).value).to include 'Procura Bien'
      expect(mail.header_fields.get_field(:from).value).to include 'noreply@procura'
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pg_rails-7.6.28 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.27 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.26 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.25 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.24 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.24.pre.5 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.24.pre.4 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.24.pre.3 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.23 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.22 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.22.pre.3 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.22.pre.2 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.22.pre.1 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb
pg_rails-7.6.21 pg_engine/spec/mailers/pg_engine/base_mailer_spec.rb