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" }
|
|
|
|
let(:last_sign_in_at) { nil }
|
2018-06-06 16:08:18 +02:00
|
|
|
|
2024-03-19 17:17:44 +01:00
|
|
|
subject { described_class.invite_admin(admin_user, token) }
|
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
|
2024-05-29 12:24:05 +02:00
|
|
|
it do
|
|
|
|
expect(subject.body).to include(admin_activate_path(token: token))
|
|
|
|
expect(subject.body).not_to include(edit_user_password_url(admin_user, reset_password_token: token))
|
|
|
|
expect(subject['BYPASS_UNVERIFIED_MAIL_PROTECTION']).to be_present
|
|
|
|
end
|
2020-09-17 15:35:40 +02:00
|
|
|
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) }
|
|
|
|
|
2024-05-29 12:24:05 +02:00
|
|
|
it do
|
|
|
|
expect(subject.subject).not_to be_empty
|
|
|
|
expect(subject['BYPASS_UNVERIFIED_MAIL_PROTECTION']).to be_present
|
|
|
|
end
|
2018-06-06 16:08:18 +02:00
|
|
|
end
|
|
|
|
end
|