2015-10-26 16:10:38 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe RootController, type: :controller do
|
|
|
|
subject { get :index }
|
|
|
|
|
|
|
|
context 'when User is connected' do
|
|
|
|
before do
|
|
|
|
sign_in create(:user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(subject).to redirect_to(users_dossiers_path) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when Gestionnaire is connected' do
|
2016-12-14 18:41:33 +01:00
|
|
|
let(:gestionnaire) { create(:gestionnaire) }
|
|
|
|
|
2015-10-26 16:10:38 +01:00
|
|
|
before do
|
2016-12-14 18:41:33 +01:00
|
|
|
sign_in gestionnaire
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when gestionnaire is affect to a procedure' do
|
|
|
|
before do
|
|
|
|
create :assign_to, procedure: (create :procedure), gestionnaire: gestionnaire
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(subject).to redirect_to(backoffice_dossiers_procedure_path(id: Procedure.all.first.id)) }
|
2015-10-26 16:10:38 +01:00
|
|
|
end
|
|
|
|
|
2016-12-14 18:41:33 +01:00
|
|
|
context 'when gestionnaire is not affect to a procedure' do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
2017-04-17 15:03:23 +02:00
|
|
|
it { expect(response.body).to have_css('.landing') }
|
2016-12-14 18:41:33 +01:00
|
|
|
end
|
2015-10-26 16:10:38 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when Administrateur is connected' do
|
|
|
|
before do
|
|
|
|
sign_in create(:administrateur)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(subject).to redirect_to(admin_procedures_path) }
|
|
|
|
end
|
|
|
|
|
2017-05-31 15:27:20 +02:00
|
|
|
context 'when Administration is connected' do
|
|
|
|
before do
|
|
|
|
sign_in create(:administration)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(subject).to redirect_to(administrations_path) }
|
|
|
|
end
|
|
|
|
|
2015-10-26 16:10:38 +01:00
|
|
|
context 'when nobody is connected' do
|
2016-02-01 17:16:00 +01:00
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
2017-06-12 15:16:15 +02:00
|
|
|
stub_request(:get, "https://api.github.com/repos/sgmap/tps/releases/latest")
|
|
|
|
.to_return(:status => 200, :body => '{"tag_name": "plip", "body": "blabla", "published_at": "2016-02-09T16:46:47Z"}', :headers => {})
|
2016-02-16 12:01:39 +01:00
|
|
|
|
2016-02-01 17:16:00 +01:00
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
2017-04-17 15:03:23 +02:00
|
|
|
it { expect(response.body).to have_css('.landing') }
|
2015-10-26 16:10:38 +01:00
|
|
|
end
|
2016-10-18 15:50:48 +02:00
|
|
|
|
|
|
|
context "unified login" do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it "won't have gestionnaire login link" do
|
|
|
|
expect(response.body).to have_css("a[href='#{new_user_session_path}']")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|