2018-06-06 16:08:18 +02:00
|
|
|
RSpec.describe AdministrationMailer, type: :mailer do
|
|
|
|
describe '#invite_admin' do
|
2020-09-17 15:35:40 +02:00
|
|
|
let(:admin_user) { create(:user, last_sign_in_at: last_sign_in_at) }
|
|
|
|
let(:token) { "some_token" }
|
2019-08-28 11:37:41 +02:00
|
|
|
let(:administration_id) { BizDev::PIPEDRIVE_ID }
|
2020-09-17 15:35:40 +02:00
|
|
|
let(:last_sign_in_at) { nil }
|
2018-06-06 16:08:18 +02:00
|
|
|
|
2020-09-17 15:35:40 +02:00
|
|
|
subject { described_class.invite_admin(admin_user, token, administration_id) }
|
2018-06-06 16:08:18 +02:00
|
|
|
|
|
|
|
it { expect(subject.subject).not_to be_empty }
|
2020-09-17 15:35:40 +02:00
|
|
|
|
|
|
|
describe "when the user has not been activated" do
|
|
|
|
it { expect(subject.body).to include(admin_activate_path(token: token)) }
|
|
|
|
it { expect(subject.body).not_to include(edit_user_password_url(admin_user, reset_password_token: token)) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when the user is already active" do
|
|
|
|
let(:last_sign_in_at) { Time.zone.now }
|
|
|
|
it { expect(subject.body).not_to include(admin_activate_path(token: token)) }
|
|
|
|
it { expect(subject.body).to include(edit_user_password_url(admin_user, reset_password_token: token)) }
|
|
|
|
end
|
2018-06-06 16:08:18 +02:00
|
|
|
end
|
|
|
|
|
2018-06-08 15:14:22 +02:00
|
|
|
describe '#refuse_admin' do
|
2018-06-06 16:08:18 +02:00
|
|
|
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
|