Merge pull request #10159 from demarches-simplifiees/dead_code

Tech: suppression de code mort relatif a pipedrive
This commit is contained in:
LeSim 2024-03-21 11:01:48 +00:00 committed by GitHub
commit 2978eb328c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 13 additions and 47 deletions

View file

@ -16,7 +16,7 @@ module Gestionnaires
if not_found_emails.present?
administrateurs_to_add += not_found_emails.map do |email|
user = User.create_or_promote_to_administrateur(email, SecureRandom.hex)
user.invite_administrateur!(@groupe_gestionnaire)
user.invite_administrateur!
user.administrateur
end
end

View file

@ -14,7 +14,7 @@ module Manager
end
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"
redirect_to manager_administrateur_path(params[:id])
end

View file

@ -1,8 +0,0 @@
module BizDev
NAME = "Équipe DS"
PIPEDRIVE_ID = 6019737
def self.full_name(administration_id)
NAME
end
end

View file

@ -2,10 +2,10 @@
class AdministrationMailer < ApplicationMailer
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
@user = user
@author_name = BizDev.full_name(administration_id)
@author_name = "Équipe de #{APPLICATION_NAME}"
subject = "Activez votre compte administrateur"
mail(to: user.email,

View file

@ -32,7 +32,7 @@ class SuperAdmin < ApplicationRecord
user = User.create_or_promote_to_administrateur(email, SecureRandom.hex)
if user.valid?
user.invite_administrateur!(id)
user.invite_administrateur!
Procedure.create_initiation_procedure(user.administrateur)
end

View file

@ -85,8 +85,8 @@ class User < ApplicationRecord
UserMailer.invite_gestionnaire(self, set_reset_password_token, groupe_gestionnaire).deliver_later
end
def invite_administrateur!(administration_id)
AdministrationMailer.invite_admin(self, set_reset_password_token, administration_id).deliver_later
def invite_administrateur!
AdministrationMailer.invite_admin(self, set_reset_password_token).deliver_later
end
def remind_invitation!

View file

@ -97,9 +97,6 @@ CRISP_CLIENT_KEY=""
# https://api.gouv.fr/api/api-entreprise.html
API_ENTREPRISE_KEY=""
# External service: CRM for following admin accounts pipeline (specific to démarches-simplifiées.fr)
PIPEDRIVE_KEY=""
# Networks bypassing the email login token that verifies new devices, and rack-attack throttling
TRUSTED_NETWORKS=""

View file

@ -1,22 +0,0 @@
describe BizDev, lib: true do
let(:first_biz_dev_id) { BizDev::PIPEDRIVE_ID }
let(:non_biz_dev_id) { first_biz_dev_id - 1 }
it { expect(BizDev::PIPEDRIVE_ID).not_to eq(non_biz_dev_id) }
describe '#full_name' do
subject { described_class.full_name(administration_id) }
context 'when administration is a business developer' do
let(:administration_id) { first_biz_dev_id }
it { is_expected.not_to be_empty }
end
context 'when administration is not a business developer' do
let(:administration_id) { non_biz_dev_id }
it { is_expected.not_to be_empty }
end
end
end

View file

@ -2,10 +2,9 @@ RSpec.describe AdministrationMailer, type: :mailer do
describe '#invite_admin' do
let(:admin_user) { create(:user, last_sign_in_at: last_sign_in_at) }
let(:token) { "some_token" }
let(:administration_id) { BizDev::PIPEDRIVE_ID }
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 }

View file

@ -1,10 +1,10 @@
class AdministrationMailerPreview < ActionMailer::Preview
def invite_admin
AdministrationMailer.invite_admin(administrateur, "12345678", 0)
AdministrationMailer.invite_admin(administrateur, "12345678")
end
def invite_admin_whose_already_has_an_account
AdministrationMailer.invite_admin(administrateur, nil, 0)
AdministrationMailer.invite_admin(administrateur, nil)
end
def refuse_admin

View file

@ -223,12 +223,12 @@ describe User, type: :model do
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
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
context 'when the user is actif' do
@ -238,7 +238,7 @@ describe User, type: :model do
end
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