Module: Onotole::Mail

Included in:
AppBuilder
Defined in:
lib/onotole/mail.rb

Instance Method Summary collapse

Instance Method Details

#configure_action_mailerObject



4
5
6
7
8
# File 'lib/onotole/mail.rb', line 4

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

#configure_action_mailer_in_specsObject



10
11
12
# File 'lib/onotole/mail.rb', line 10

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

#configure_smtpObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/onotole/mail.rb', line 14

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

#raise_on_delivery_errorsObject



38
39
40
41
# File 'lib/onotole/mail.rb', line 38

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

#set_test_delivery_methodObject



30
31
32
33
34
35
36
# File 'lib/onotole/mail.rb', line 30

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