Create the mail method from db:seed

As opposed the to sample users and enterprises that ease testing and
development, the mail method is needed for the app to function in any
environment.
This commit is contained in:
Pau Perez
2018-03-16 13:05:17 +01:00
parent 7afc999689
commit f27a624687
2 changed files with 21 additions and 21 deletions

View File

@@ -29,3 +29,24 @@ states.each do |state|
)
end
end
create_mail_method
def create_mail_method
Spree::MailMethod.destroy_all
CreateMailMethod.new(
environment: Rails.env,
preferred_enable_mail_delivery: true,
preferred_mail_host: ENV['MAIL_HOST'],
preferred_mail_domain: ENV['MAIL_DOMAIN'],
preferred_mail_port: ENV['MAIL_PORT'],
preferred_mail_auth_type: 'login',
preferred_smtp_username: ENV['SMTP_USERNAME'],
preferred_smtp_password: ENV['SMTP_PASSWORD'],
preferred_secure_connection_type: 'None',
preferred_mails_from: "no-reply@#{ENV['MAIL_DOMAIN']}",
preferred_mail_bcc: '',
preferred_intercept_email: ''
).call
end

View File

@@ -13,8 +13,6 @@ namespace :openfoodnetwork do
country = Spree::Country.find_by_iso(ENV.fetch('DEFAULT_COUNTRY_CODE'))
state = country.states.first
create_mail_method
# -- Shipping / payment information
unless Spree::Zone.find_by_name 'Australia'
puts "[#{task_name}] Seeding shipping / payment information"
@@ -207,24 +205,5 @@ namespace :openfoodnetwork do
spree_user.confirm!
end
def create_mail_method
Spree::MailMethod.destroy_all
CreateMailMethod.new(
environment: Rails.env,
preferred_enable_mail_delivery: true,
preferred_mail_host: ENV['MAIL_HOST'],
preferred_mail_domain: ENV['MAIL_DOMAIN'],
preferred_mail_port: ENV['MAIL_PORT'],
preferred_mail_auth_type: "login",
preferred_smtp_username: ENV['SMTP_USERNAME'],
preferred_smtp_password: ENV['SMTP_PASSWORD'],
preferred_secure_connection_type: "None",
preferred_mails_from: "no-reply@#{ENV['MAIL_DOMAIN']}",
preferred_mail_bcc: "",
preferred_intercept_email: ""
).call
end
end
end