2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-10-26 16:10:38 +01:00
|
|
|
describe RootController, type: :controller do
|
|
|
|
subject { get :index }
|
|
|
|
|
|
|
|
context 'when User is connected' do
|
|
|
|
before do
|
|
|
|
sign_in create(:user)
|
|
|
|
end
|
|
|
|
|
2018-06-27 14:47:02 +02:00
|
|
|
it { expect(subject).to redirect_to(dossiers_path) }
|
2015-10-26 16:10:38 +01:00
|
|
|
end
|
|
|
|
|
2023-12-14 10:07:34 +01:00
|
|
|
context 'when Expert is connected' do
|
|
|
|
let(:expert) { create(:expert) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(expert.user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(subject).to redirect_to(expert_all_avis_path) }
|
|
|
|
end
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
context 'when Instructeur is connected' do
|
|
|
|
let(:instructeur) { create(:instructeur) }
|
2017-12-19 15:08:08 +01:00
|
|
|
let(:procedure) { create(:procedure, :published) }
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
2016-12-14 18:41:33 +01:00
|
|
|
|
2015-10-26 16:10:38 +01:00
|
|
|
before do
|
2019-08-20 18:03:33 +02:00
|
|
|
instructeur.groupe_instructeurs << procedure.defaut_groupe_instructeur
|
2019-08-07 11:15:16 +02:00
|
|
|
sign_in(instructeur.user)
|
2016-12-14 18:41:33 +01:00
|
|
|
end
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
it { expect(subject).to redirect_to(instructeur_procedures_path) }
|
2015-10-26 16:10:38 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when Administrateur is connected' do
|
|
|
|
before do
|
2024-06-01 22:50:48 +02:00
|
|
|
sign_in(administrateurs(:default_admin).user)
|
2015-10-26 16:10:38 +01:00
|
|
|
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
|
2020-11-05 15:09:11 +01:00
|
|
|
sign_in create(:super_admin)
|
2017-05-31 15:27:20 +02:00
|
|
|
end
|
|
|
|
|
2018-01-16 17:09:25 +01:00
|
|
|
it { expect(subject).to redirect_to(manager_root_path) }
|
2017-05-31 15:27:20 +02:00
|
|
|
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
|
2018-01-10 17:26:12 +01:00
|
|
|
stub_request(:get, "https://api.github.com/repos/betagouv/tps/releases/latest")
|
2018-01-15 19:34:08 +01:00
|
|
|
.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
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
it "won't have instructeur login link" do
|
2016-10-18 15:50:48 +02:00
|
|
|
expect(response.body).to have_css("a[href='#{new_user_session_path}']")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|