From dba1ab55d938d3cbd5b64523208613829080091a Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 5 Jun 2018 18:45:14 +0200 Subject: [PATCH 1/3] Added PIR to parsers list --- app/services/whois/parser.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/whois/parser.rb b/app/services/whois/parser.rb index 9b53089..bc54ec4 100644 --- a/app/services/whois/parser.rb +++ b/app/services/whois/parser.rb @@ -1,11 +1,12 @@ require "null_logger" require "whois/errors" require "whois/parser/afnic" +require "whois/parser/pir" require "whois/parser/verisign" module Whois module Parser - PARSERS = [AFNIC, Verisign].freeze + PARSERS = [AFNIC, Verisign, PIR].freeze class << self def for(domain, logger: NullLogger.new) From 8ff94076c02fa49ac53cf91d66bfa4b21cca3659 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 5 Jun 2018 20:09:00 +0200 Subject: [PATCH 2/3] Dynamic mailer configuration --- config/chexpire.example.yml | 4 ++++ config/environments/development.rb | 4 ++++ config/environments/production.rb | 6 ++++-- config/environments/staging.rb | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/config/chexpire.example.yml b/config/chexpire.example.yml index 2e4ce13..ceefa0f 100644 --- a/config/chexpire.example.yml +++ b/config/chexpire.example.yml @@ -12,5 +12,9 @@ development: <<: *default host: "chexpire.local" +production: + action_mailer_config: + delivery_method: :sendmail + # test configuration included in file used by CI services <%= IO.read Rails.root.join("config", "chexpire.test.yml") %> diff --git a/config/environments/development.rb b/config/environments/development.rb index 1888e36..12fa719 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -44,6 +44,10 @@ Rails.application.configure do config.action_mailer.default_url_options = { host: config.chexpire.fetch("host"), port: 3000 } + config.chexpire.fetch("action_mailer_config", {}).each_pair do |key, value| + config.action_mailer[key] = value + end + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log diff --git a/config/environments/production.rb b/config/environments/production.rb index 0ea521f..45a7f1e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -65,10 +65,12 @@ Rails.application.configure do # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false - config.action_mailer.default_url_options = { host: 'chexpire.evolix.org' } - config.action_mailer.default_url_options = { host: config.chexpire.fetch("host") } + config.chexpire.fetch("action_mailer_config", {}).each_pair do |key, value| + config.action_mailer[key] = value + end + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true diff --git a/config/environments/staging.rb b/config/environments/staging.rb index cc4ffa9..710e2cc 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -67,6 +67,9 @@ Rails.application.configure do # config.action_mailer.raise_delivery_errors = false config.action_mailer.default_url_options = { host: config.chexpire.fetch("host") } + config.chexpire.fetch("action_mailer_config", {}).each_pair do |key, value| + config.action_mailer[key] = value + end # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). From a0cec2aa9678aa2c5c265213e5979f9c29093aca Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 5 Jun 2018 20:18:41 +0200 Subject: [PATCH 3/3] Devise send email notifiation async --- app/models/user.rb | 5 +++++ test/system/users_test.rb | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index adbbc7b..e757d78 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -39,4 +39,9 @@ class User < ApplicationRecord validates :tos_accepted, acceptance: true scope :notifications_disabled, -> { where(notifications_enabled: false) } + + # Devise ActiveJob integration + def send_devise_notification(notification, *args) + devise_mailer.send(notification, self, *args).deliver_later + end end diff --git a/test/system/users_test.rb b/test/system/users_test.rb index d7fe931..3191255 100644 --- a/test/system/users_test.rb +++ b/test/system/users_test.rb @@ -17,7 +17,11 @@ class UsersTest < ApplicationSystemTestCase fill_in("user[password_confirmation]", with: password) check "user[tos_accepted]" - click_button I18n.t("devise.registrations.new.sign_up") + # confirmation email is sent in async + perform_enqueued_jobs do + click_button I18n.t("devise.registrations.new.sign_up") + end + assert_performed_jobs 1 assert_equal root_path, page.current_path user = User.find_by!(email: email, confirmed_at: nil)