Merge pull request #2054 from betagouv/fix-bizdev-mailer
Fix bizdev mailer
This commit is contained in:
commit
1193feb5f8
3 changed files with 79 additions and 3 deletions
|
@ -24,13 +24,13 @@ module BizDev
|
|||
|
||||
BIZ_DEV_IDS = BIZ_DEV_MAPPING.keys
|
||||
|
||||
def full_name(administration_id)
|
||||
def self.full_name(administration_id)
|
||||
id = ensure_proper_administration_id(administration_id)
|
||||
|
||||
BIZ_DEV_MAPPING[id][:full_name]
|
||||
end
|
||||
|
||||
def pipedrive_id(administration_id)
|
||||
def self.pipedrive_id(administration_id)
|
||||
id = ensure_proper_administration_id(administration_id)
|
||||
|
||||
BIZ_DEV_MAPPING[id][:pipedrive_id]
|
||||
|
@ -38,7 +38,7 @@ module BizDev
|
|||
|
||||
private
|
||||
|
||||
def ensure_proper_administration_id(administration_id)
|
||||
def self.ensure_proper_administration_id(administration_id)
|
||||
if administration_id.in?(BIZ_DEV_IDS)
|
||||
administration_id
|
||||
else
|
||||
|
|
40
spec/lib/biz_dev_spec.rb
Normal file
40
spec/lib/biz_dev_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe BizDev, lib: true do
|
||||
let(:first_biz_dev_id) { BizDev::BIZ_DEV_IDS.first }
|
||||
let(:non_biz_dev_id) { first_biz_dev_id - 1 }
|
||||
|
||||
it { expect(BizDev::BIZ_DEV_MAPPING).not_to include(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
|
||||
|
||||
describe '#pipedrive_id' do
|
||||
subject { described_class.pipedrive_id(administration_id) }
|
||||
|
||||
context 'when administration is a business developer' do
|
||||
let(:administration_id) { first_biz_dev_id }
|
||||
|
||||
it { is_expected.to be > 0 }
|
||||
end
|
||||
|
||||
context 'when administration is not a business developer' do
|
||||
let(:administration_id) { non_biz_dev_id }
|
||||
|
||||
it { is_expected.to be > 0 }
|
||||
end
|
||||
end
|
||||
end
|
36
spec/mailers/administration_mailer_spec.rb
Normal file
36
spec/mailers/administration_mailer_spec.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
RSpec.describe AdministrationMailer, type: :mailer do
|
||||
describe '#new_admin_email' do
|
||||
let(:admin) { create(:administrateur) }
|
||||
let(:administration) { create(:administration) }
|
||||
|
||||
subject { described_class.new_admin_email(admin, administration) }
|
||||
|
||||
it { expect(subject.subject).not_to be_empty }
|
||||
end
|
||||
|
||||
describe '#invite_admin' do
|
||||
let(:admin) { create(:administrateur) }
|
||||
let(:token) { "Toc toc toc" }
|
||||
let(:administration_id) { BizDev::BIZ_DEV_IDS.first }
|
||||
|
||||
subject { described_class.invite_admin(admin, token, administration_id) }
|
||||
|
||||
it { expect(subject.subject).not_to be_empty }
|
||||
end
|
||||
|
||||
describe '#refuse_amin' do
|
||||
let(:mail) { "l33t-4dm1n@h4x0r.com" }
|
||||
|
||||
subject { described_class.refuse_admin(mail) }
|
||||
|
||||
it { expect(subject.subject).not_to be_empty }
|
||||
end
|
||||
|
||||
describe '#dubious_procedures' do
|
||||
let(:procedures_and_type_de_champs) { [] }
|
||||
|
||||
subject { described_class.dubious_procedures(procedures_and_type_de_champs) }
|
||||
|
||||
it { expect(subject.subject).not_to be_empty }
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue