From f27a6246876f7e7ba2346d80ddea455cd2af3e47 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Fri, 16 Mar 2018 13:05:17 +0100 Subject: [PATCH] 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. --- db/seeds.rb | 21 +++++++++++++++++++++ lib/tasks/dev.rake | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 9f9bc1efca..68bbc01866 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -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 diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 9bfbb69e3d..4bf1c58c3c 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -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