remove useless administration_id in invite_admin and invite_administrateur!
This commit is contained in:
parent
31124123e1
commit
a42f85ef05
8 changed files with 13 additions and 14 deletions
|
@ -16,7 +16,7 @@ module Gestionnaires
|
||||||
if not_found_emails.present?
|
if not_found_emails.present?
|
||||||
administrateurs_to_add += not_found_emails.map do |email|
|
administrateurs_to_add += not_found_emails.map do |email|
|
||||||
user = User.create_or_promote_to_administrateur(email, SecureRandom.hex)
|
user = User.create_or_promote_to_administrateur(email, SecureRandom.hex)
|
||||||
user.invite_administrateur!(@groupe_gestionnaire)
|
user.invite_administrateur!
|
||||||
user.administrateur
|
user.administrateur
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Manager
|
||||||
end
|
end
|
||||||
|
|
||||||
def reinvite
|
def reinvite
|
||||||
Administrateur.find_inactive_by_id(params[:id]).user.invite_administrateur!(current_super_admin.id)
|
Administrateur.find_inactive_by_id(params[:id]).user.invite_administrateur!
|
||||||
flash.notice = "Invitation renvoyée"
|
flash.notice = "Invitation renvoyée"
|
||||||
redirect_to manager_administrateur_path(params[:id])
|
redirect_to manager_administrateur_path(params[:id])
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
class AdministrationMailer < ApplicationMailer
|
class AdministrationMailer < ApplicationMailer
|
||||||
layout 'mailers/layout'
|
layout 'mailers/layout'
|
||||||
|
|
||||||
def invite_admin(user, reset_password_token, administration_id)
|
def invite_admin(user, reset_password_token)
|
||||||
@reset_password_token = reset_password_token
|
@reset_password_token = reset_password_token
|
||||||
@user = user
|
@user = user
|
||||||
@author_name = BizDev.full_name(administration_id)
|
@author_name = "Équipe de #{APPLICATION_NAME}"
|
||||||
subject = "Activez votre compte administrateur"
|
subject = "Activez votre compte administrateur"
|
||||||
|
|
||||||
mail(to: user.email,
|
mail(to: user.email,
|
||||||
|
|
|
@ -32,7 +32,7 @@ class SuperAdmin < ApplicationRecord
|
||||||
user = User.create_or_promote_to_administrateur(email, SecureRandom.hex)
|
user = User.create_or_promote_to_administrateur(email, SecureRandom.hex)
|
||||||
|
|
||||||
if user.valid?
|
if user.valid?
|
||||||
user.invite_administrateur!(id)
|
user.invite_administrateur!
|
||||||
Procedure.create_initiation_procedure(user.administrateur)
|
Procedure.create_initiation_procedure(user.administrateur)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,8 @@ class User < ApplicationRecord
|
||||||
UserMailer.invite_gestionnaire(self, set_reset_password_token, groupe_gestionnaire).deliver_later
|
UserMailer.invite_gestionnaire(self, set_reset_password_token, groupe_gestionnaire).deliver_later
|
||||||
end
|
end
|
||||||
|
|
||||||
def invite_administrateur!(administration_id)
|
def invite_administrateur!
|
||||||
AdministrationMailer.invite_admin(self, set_reset_password_token, administration_id).deliver_later
|
AdministrationMailer.invite_admin(self, set_reset_password_token).deliver_later
|
||||||
end
|
end
|
||||||
|
|
||||||
def remind_invitation!
|
def remind_invitation!
|
||||||
|
|
|
@ -2,10 +2,9 @@ RSpec.describe AdministrationMailer, type: :mailer do
|
||||||
describe '#invite_admin' do
|
describe '#invite_admin' do
|
||||||
let(:admin_user) { create(:user, last_sign_in_at: last_sign_in_at) }
|
let(:admin_user) { create(:user, last_sign_in_at: last_sign_in_at) }
|
||||||
let(:token) { "some_token" }
|
let(:token) { "some_token" }
|
||||||
let(:administration_id) { BizDev::PIPEDRIVE_ID }
|
|
||||||
let(:last_sign_in_at) { nil }
|
let(:last_sign_in_at) { nil }
|
||||||
|
|
||||||
subject { described_class.invite_admin(admin_user, token, administration_id) }
|
subject { described_class.invite_admin(admin_user, token) }
|
||||||
|
|
||||||
it { expect(subject.subject).not_to be_empty }
|
it { expect(subject.subject).not_to be_empty }
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
class AdministrationMailerPreview < ActionMailer::Preview
|
class AdministrationMailerPreview < ActionMailer::Preview
|
||||||
def invite_admin
|
def invite_admin
|
||||||
AdministrationMailer.invite_admin(administrateur, "12345678", 0)
|
AdministrationMailer.invite_admin(administrateur, "12345678")
|
||||||
end
|
end
|
||||||
|
|
||||||
def invite_admin_whose_already_has_an_account
|
def invite_admin_whose_already_has_an_account
|
||||||
AdministrationMailer.invite_admin(administrateur, nil, 0)
|
AdministrationMailer.invite_admin(administrateur, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
def refuse_admin
|
def refuse_admin
|
||||||
|
|
|
@ -223,12 +223,12 @@ describe User, type: :model do
|
||||||
|
|
||||||
before { allow(AdministrationMailer).to receive(:invite_admin).and_return(mailer_double) }
|
before { allow(AdministrationMailer).to receive(:invite_admin).and_return(mailer_double) }
|
||||||
|
|
||||||
subject { user.invite_administrateur!(super_admin.id) }
|
subject { user.invite_administrateur! }
|
||||||
|
|
||||||
context 'when the user is inactif' do
|
context 'when the user is inactif' do
|
||||||
before { subject }
|
before { subject }
|
||||||
|
|
||||||
it { expect(AdministrationMailer).to have_received(:invite_admin).with(user, kind_of(String), super_admin.id) }
|
it { expect(AdministrationMailer).to have_received(:invite_admin).with(user, kind_of(String)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the user is actif' do
|
context 'when the user is actif' do
|
||||||
|
@ -238,7 +238,7 @@ describe User, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'receives an invitation to update its password' do
|
it 'receives an invitation to update its password' do
|
||||||
expect(AdministrationMailer).to have_received(:invite_admin).with(user, kind_of(String), super_admin.id)
|
expect(AdministrationMailer).to have_received(:invite_admin).with(user, kind_of(String))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue