2018-01-17 10:28:59 +01:00
|
|
|
describe Manager::AdministrateursController, type: :controller do
|
|
|
|
let(:administration){ create(:administration) }
|
|
|
|
|
|
|
|
describe 'POST #create' do
|
|
|
|
let(:email) { 'plop@plop.com' }
|
|
|
|
let(:password) { 'password' }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in administration
|
|
|
|
end
|
|
|
|
|
2018-01-23 18:16:44 +01:00
|
|
|
subject { post :create, params: { administrateur: { email: email } } }
|
2018-01-17 10:28:59 +01:00
|
|
|
|
|
|
|
context 'when email and password are correct' do
|
|
|
|
it 'add new administrateur in database' do
|
|
|
|
expect { subject }.to change(Administrateur, :count).by(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'alert new mail are send' do
|
|
|
|
expect(AdministrationMailer).to receive(:new_admin_email).and_return(AdministrationMailer)
|
2018-05-25 18:05:28 +02:00
|
|
|
expect(AdministrationMailer).to receive(:deliver_later)
|
2018-01-17 10:28:59 +01:00
|
|
|
expect(AdministrationMailer).to receive(:invite_admin).and_return(AdministrationMailer)
|
2018-05-25 18:05:28 +02:00
|
|
|
expect(AdministrationMailer).to receive(:deliver_later)
|
2018-01-17 10:28:59 +01:00
|
|
|
subject
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when email or password are missing' do
|
|
|
|
let(:email) { '' }
|
|
|
|
|
|
|
|
it { expect { subject }.to change(Administrateur, :count).by(0) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|