Sha256: 84f903a7c1d943163326f03dc189d4c4ef2634d7ef5b4b387436a13cd1cdcffd

Contents?: true

Size: 1.33 KB

Versions: 31

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true
module Onotole
  module Mail
    def configure_action_mailer
      action_mailer_host 'development', %("localhost:3000")
      action_mailer_host 'test', %("www.example.com")
      action_mailer_host 'production', %{ENV.fetch("#{app_name.upcase}_APPLICATION_HOST")}
    end

    def configure_action_mailer_in_specs
      copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb'
    end

    def configure_smtp
      template 'smtp.rb.erb', 'config/smtp.rb', force: true

      prepend_file 'config/environments/production.rb',
                   %{require Rails.root.join("config/smtp")\n}

      config = <<-RUBY

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = SMTP_SETTINGS
      RUBY

      inject_into_file 'config/environments/production.rb', config,
                       after: 'config.action_mailer.raise_delivery_errors = false'
    end

    def set_test_delivery_method
      inject_into_file(
        'config/environments/development.rb',
        "\n  config.action_mailer.delivery_method = :file",
        after: 'config.action_mailer.raise_delivery_errors = true'
      )
    end

    def raise_on_delivery_errors
      replace_in_file 'config/environments/development.rb',
                      'raise_delivery_errors = false', 'raise_delivery_errors = true'
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
onotole-2.0.2 lib/onotole/mail.rb
onotole-2.0.1 lib/onotole/mail.rb
onotole-2.0.0 lib/onotole/mail.rb
onotole-1.2.11 lib/onotole/mail.rb
onotole-1.2.10 lib/onotole/mail.rb
onotole-1.2.9 lib/onotole/mail.rb
onotole-1.2.8 lib/onotole/mail.rb
onotole-1.2.7 lib/onotole/mail.rb
onotole-1.2.6 lib/onotole/mail.rb
onotole-1.2.5 lib/onotole/mail.rb
onotole-1.2.4 lib/onotole/mail.rb
onotole-1.2.3 lib/onotole/mail.rb
onotole-1.2.2 lib/onotole/mail.rb
onotole-1.2.1 lib/onotole/mail.rb
onotole-1.1.21 lib/onotole/mail.rb
onotole-1.1.20 lib/onotole/mail.rb
onotole-1.1.19 lib/onotole/mail.rb
onotole-1.1.18 lib/onotole/mail.rb
onotole-1.1.17 lib/onotole/mail.rb
onotole-1.1.16 lib/onotole/mail.rb