Add tests for demo devise sessions
This commit is contained in:
parent
f21f151c9c
commit
2aebf9933c
3 changed files with 45 additions and 6 deletions
|
@ -5,6 +5,27 @@ describe Administrateurs::SessionsController, type: :controller do
|
|||
@request.env["devise.mapping"] = Devise.mappings[:administrateur]
|
||||
end
|
||||
|
||||
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
|
||||
expect(Administrateur).to receive(:new).with(email: 'admin@tps.fr', password: 'password').and_return(Administrateur)
|
||||
subject
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.create' do
|
||||
it { expect(described_class).to be < Sessions::SessionsController }
|
||||
end
|
||||
|
|
|
@ -6,14 +6,23 @@ describe Gestionnaires::SessionsController, type: :controller do
|
|||
end
|
||||
|
||||
describe '.demo' do
|
||||
context 'when server is on env production' 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
|
||||
subject { get :demo }
|
||||
|
||||
it { expect(subject).to redirect_to root_path }
|
||||
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 'Gestionnaire demo is initiated' do
|
||||
expect(Gestionnaire).to receive(:new).with(email: 'gestionnaire@apientreprise.fr', password: 'password').and_return(Gestionnaire)
|
||||
subject
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -9,14 +9,23 @@ describe Users::SessionsController, type: :controller do
|
|||
end
|
||||
|
||||
describe '.demo' do
|
||||
context 'when server is on env production' 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
|
||||
subject { get :demo }
|
||||
|
||||
it { expect(subject).to redirect_to root_path }
|
||||
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 'User demo is initiated' do
|
||||
expect(User).to receive(:new).with(email: 'demo@tps.fr', password: 'password').and_return(User)
|
||||
subject
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue