[Fix #1972] Make devise mails async

This commit is contained in:
Frederic Merizen 2018-05-26 00:06:40 +02:00
parent 07b1c147d9
commit fd168c4a72
7 changed files with 12 additions and 6 deletions

View file

@ -42,6 +42,7 @@ gem 'unicode_utils'
# Gestion des comptes utilisateurs
gem 'devise'
gem 'devise-async'
gem 'openid_connect'
gem 'omniauth-github'

View file

@ -175,6 +175,9 @@ GEM
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
devise-async (1.0.0)
activejob (>= 5.0)
devise (>= 4.0)
diff-lcs (1.3)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
@ -803,6 +806,7 @@ DEPENDENCIES
delayed_job_active_record
delayed_job_web!
devise
devise-async
dotenv-rails
draper
factory_bot

View file

@ -2,7 +2,7 @@ class Administrateur < ApplicationRecord
include CredentialsSyncableConcern
include EmailSanitizableConcern
devise :database_authenticatable, :registerable,
devise :database_authenticatable, :registerable, :async,
:recoverable, :rememberable, :trackable, :validatable
has_and_belongs_to_many :gestionnaires

View file

@ -1,7 +1,7 @@
class Administration < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :rememberable, :trackable, :validatable, :omniauthable, omniauth_providers: [:github]
devise :database_authenticatable, :rememberable, :trackable, :validatable, :omniauthable, :async, omniauth_providers: [:github]
def self.from_omniauth(params)
find_by(email: params["info"]["email"])

View file

@ -2,7 +2,7 @@ class Gestionnaire < ApplicationRecord
include CredentialsSyncableConcern
include EmailSanitizableConcern
devise :database_authenticatable, :registerable,
devise :database_authenticatable, :registerable, :async,
:recoverable, :rememberable, :trackable, :validatable
has_and_belongs_to_many :administrateurs

View file

@ -9,7 +9,7 @@ class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
devise :database_authenticatable, :registerable, :async,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
has_many :dossiers, dependent: :destroy

View file

@ -15,8 +15,9 @@ describe Users::RegistrationsController, type: :controller do
context 'when user is correct' do
it 'sends confirmation instruction' do
expect(DeviseUserMailer).to receive(:confirmation_instructions).and_return(DeviseUserMailer)
expect(DeviseUserMailer).to receive(:deliver)
message = double()
expect(DeviseUserMailer).to receive(:confirmation_instructions).and_return(message)
expect(message).to receive(:deliver_later)
subject
end