diff --git a/Gemfile b/Gemfile index 987c75ec5..4127ede86 100644 --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,7 @@ gem 'unicode_utils' # Gestion des comptes utilisateurs gem 'devise' +gem 'devise-async' gem 'openid_connect' gem 'omniauth-github' diff --git a/Gemfile.lock b/Gemfile.lock index e7116b9f6..110b9c397 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/models/administrateur.rb b/app/models/administrateur.rb index 164ff18be..e4fd48ca8 100644 --- a/app/models/administrateur.rb +++ b/app/models/administrateur.rb @@ -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 diff --git a/app/models/administration.rb b/app/models/administration.rb index bfc452d63..2428749f3 100644 --- a/app/models/administration.rb +++ b/app/models/administration.rb @@ -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"]) diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 253fc1523..76b737e9a 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 1bd1668a7..2de403c64 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/spec/controllers/users/registrations_controller_spec.rb b/spec/controllers/users/registrations_controller_spec.rb index 36d26d9de..8fe725f9f 100644 --- a/spec/controllers/users/registrations_controller_spec.rb +++ b/spec/controllers/users/registrations_controller_spec.rb @@ -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