In dev mode, demo buttons link to localhost

This commit is contained in:
Mathieu Magnin 2017-01-19 17:25:50 +01:00
parent 566fd8bc74
commit f15e9ec7da
3 changed files with 33 additions and 4 deletions

View file

@ -43,6 +43,8 @@ class RootController < ApplicationController
return redirect_to administrations_path
end
@demo_environment_host = "https://tps-dev.apientreprise.fr" unless Rails.env.development?
render 'landing'
end
end

View file

@ -44,18 +44,19 @@
.col-md-4.col-lg-4
%h3.text-primary Acteurs publics
%h4 Créez des démarches en ligne simplifiées et sécurisées.
=link_to 'Démonstration', 'https://tps-dev.apientreprise.fr/administrateurs/sign_in/demo', {class: 'btn btn-lg btn-primary'}
=link_to 'Démonstration', "#{@demo_environment_host}/administrateurs/sign_in/demo", {class: 'btn btn-lg btn-primary'}
.col-md-4.col-lg-4
%h3.text-warning Agents et services
%h4 Accompagnez et co-traitez les projets avec les usagers.
=link_to 'Démonstration', 'https://tps-dev.apientreprise.fr/gestionnaires/sign_in/demo', {class: 'btn btn-lg btn-warning'}
=link_to 'Démonstration', "#{@demo_environment_host}/gestionnaires/sign_in/demo", {class: 'btn btn-lg btn-warning'}
.col-md-4.col-lg-4
%h3.text-success Usagers
%h4 Profitez de démarches simplifiées et déchanges continus avec les services traitants.
=link_to 'Démonstration', 'https://tps-dev.apientreprise.fr/users/sign_in/demo', {class: 'btn btn-lg btn-success'}
=link_to 'Démonstration', "#{@demo_environment_host}/users/sign_in/demo", {class: 'btn btn-lg btn-success'}
%h1
= @demo_environment_host
.split-hr-left
.center

View file

@ -56,6 +56,31 @@ describe RootController, type: :controller do
end
it { expect(response.body).to have_css('#landing') }
end
context 'environment is not development' do
render_views
before do
Rails.env.stub(:development? => false)
subject
end
it { expect(response.body).to have_link('Démonstration', href: "https://tps-dev.apientreprise.fr#{ users_sign_in_demo_path }") }
end
context 'environment is development' do
render_views
before do
Rails.env.stub(:development? => true)
subject
end
it { expect(response.body).to have_link('Démonstration', href: users_sign_in_demo_path) }
end
context 'when opensimplif features is true' do
@ -81,4 +106,5 @@ describe RootController, type: :controller do
expect(response.body).to have_css("a[href='#{new_user_session_path}']")
end
end
end