Skip to content

Commit

Permalink
Add mailers' preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Beljajev committed Mar 28, 2019
1 parent 5d63feb commit b06b99a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class Application < Rails::Application
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true

# Override "spec/mailers/previews" that RSpec sets
config.action_mailer.preview_path = "#{Rails.root}/test/mailers/previews"

config.action_mailer.smtp_settings = {
address: ENV['smtp_address'],
port: ENV['smtp_port'],
Expand Down
4 changes: 4 additions & 0 deletions config/environments/staging-example.rb
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
require_relative 'production'

Rails.application.configure do
config.action_mailer.show_previews = true
end
15 changes: 15 additions & 0 deletions test/mailers/previews/domain_delete_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class DomainDeleteMailerPreview < ActionMailer::Preview
def self.define_forced_templates
DomainDeleteMailer.force_delete_templates.each do |template_name|
define_method "forced_#{template_name}".to_sym do
domain = Domain.first
DomainDeleteMailer.forced(domain: domain,
registrar: domain.registrar,
registrant: domain.registrant,
template_name: template_name)
end
end
end

define_forced_templates
end
7 changes: 7 additions & 0 deletions test/mailers/previews/domain_expire_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class DomainExpireMailerPreview < ActionMailer::Preview
def expired
domain = Domain.first
DomainExpireMailer.expired(domain: domain,
registrar: domain.registrar)
end
end

0 comments on commit b06b99a

Please sign in to comment.