2015-12-09 15:10:11 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Administrateurs::SessionsController, type: :controller do
|
|
|
|
before do
|
|
|
|
@request.env["devise.mapping"] = Devise.mappings[:administrateur]
|
|
|
|
end
|
|
|
|
|
2016-12-16 10:59:16 +01:00
|
|
|
describe '.demo' do
|
|
|
|
subject { get :demo }
|
|
|
|
|
|
|
|
context 'when rails env is production' do
|
|
|
|
before do
|
|
|
|
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("production"))
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to redirect_to root_path }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when rails env is not production' do
|
|
|
|
it { expect(subject.status).to eq 200 }
|
|
|
|
|
|
|
|
it 'Administrateur demo is initiated' do
|
2017-01-03 11:34:29 +01:00
|
|
|
expect(User).to receive(:new).with(email: 'admin@tps.fr', password: 'password').and_return(Administrateur)
|
2016-12-16 10:59:16 +01:00
|
|
|
subject
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-12-09 15:10:11 +01:00
|
|
|
describe '.create' do
|
|
|
|
it { expect(described_class).to be < Sessions::SessionsController }
|
|
|
|
end
|
|
|
|
end
|