From cb2786bb3341511569184121994a265b297f248b Mon Sep 17 00:00:00 2001 From: Xavier J Date: Mon, 21 Sep 2015 11:36:26 +0200 Subject: [PATCH] =?UTF-8?q?[#876]=20New=20home=20page=20and=20disabled=20l?= =?UTF-8?q?iste=20d=C3=A9marche=20and=20cargo=20Bugs=20know=20:=20can=20no?= =?UTF-8?q?t=20access=20at=20the=20page=20"D=C3=A9tails=20de=20votre=20pro?= =?UTF-8?q?jet"=20=3D>=20"demarche"=20is=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/dossiers.scss | 4 + app/assets/stylesheets/start.scss | 5 + app/controllers/dossiers_controller.rb | 33 ++----- app/views/dossiers/show.html.haml | 2 +- app/views/start/_pro.html.haml | 11 +-- app/views/start/index.html.haml | 14 +-- spec/controllers/dossiers_controller_spec.rb | 50 +++++----- spec/features/dossiers_page/show_page_spec.rb | 33 ------- spec/features/start_page/index_page_spec.rb | 97 ------------------- .../dossiers}/_infos_dossier_spec.rb | 0 .../dossiers}/_infos_entreprise_spec.rb | 0 spec/views/dossiers/show.html.haml_spec.rb | 23 +++++ spec/views/start/index.html.haml_spec.rb | 27 ++++++ 13 files changed, 103 insertions(+), 196 deletions(-) delete mode 100644 spec/features/dossiers_page/show_page_spec.rb delete mode 100644 spec/features/start_page/index_page_spec.rb rename spec/{features/dossiers_page => views/dossiers}/_infos_dossier_spec.rb (100%) rename spec/{features/dossiers_page => views/dossiers}/_infos_entreprise_spec.rb (100%) create mode 100644 spec/views/start/index.html.haml_spec.rb diff --git a/app/assets/stylesheets/dossiers.scss b/app/assets/stylesheets/dossiers.scss index 1a80514c1..3e4769e86 100644 --- a/app/assets/stylesheets/dossiers.scss +++ b/app/assets/stylesheets/dossiers.scss @@ -4,4 +4,8 @@ h5 span { font-weight: normal +} + +#insee_infogreffe { + font-size:17px; } \ No newline at end of file diff --git a/app/assets/stylesheets/start.scss b/app/assets/stylesheets/start.scss index 6663199bd..0bf56056a 100644 --- a/app/assets/stylesheets/start.scss +++ b/app/assets/stylesheets/start.scss @@ -4,4 +4,9 @@ .mask { display: none; +} + +#titre_procedure { + margin-top: 3%; + margin-bottom: 2%; } \ No newline at end of file diff --git a/app/controllers/dossiers_controller.rb b/app/controllers/dossiers_controller.rb index d251fb958..becf918dc 100644 --- a/app/controllers/dossiers_controller.rb +++ b/app/controllers/dossiers_controller.rb @@ -9,32 +9,19 @@ class DossiersController < ApplicationController end def create - @dossier_id = params[:pro_dossier_id].strip - if dossier_id_is_present? + @etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params) + @entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params) + @dossier = Dossier.create - @dossier = Dossier.find(@dossier_id) + @entreprise.dossier = @dossier + @entreprise.save - if @dossier.siret == params[:siret] - redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier_id) - else - redirect_to url_for(controller: :start, action: :error_dossier) - end - else + @etablissement.dossier = @dossier + @etablissement.entreprise = @entreprise + @etablissement.save - @etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params) - @entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params) - @dossier = Dossier.create - - @entreprise.dossier = @dossier - @entreprise.save - - @etablissement.dossier = @dossier - @etablissement.entreprise = @entreprise - @etablissement.save - - redirect_to url_for(controller: :dossiers, action: :show, id: @dossier.id) - end + redirect_to url_for(controller: :dossiers, action: :show, id: @dossier.id) rescue RestClient::ResourceNotFound redirect_to url_for(controller: :start, action: :error_siret) @@ -46,7 +33,7 @@ class DossiersController < ApplicationController @dossier = Dossier.find(params[:id]) if checked_autorisation_donnees? @dossier.update_attributes(update_params) - redirect_to url_for(controller: :demandes, action: :show, dossier_id: @dossier.id) + redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id) else @etablissement = @dossier.etablissement @entreprise = @dossier.entreprise.decorate diff --git a/app/views/dossiers/show.html.haml b/app/views/dossiers/show.html.haml index b414270c1..166913fbc 100644 --- a/app/views/dossiers/show.html.haml +++ b/app/views/dossiers/show.html.haml @@ -1,5 +1,5 @@ .container - %h2 Récapitulatif de vos informations (récupérées auprès de l'INSEE et d'INFOGREFFE) + %h2 Récapitulatif de vos informations (récupérées auprès de l'INSEE et d'INFOGREFFE) %br %div.row diff --git a/app/views/start/_pro.html.haml b/app/views/start/_pro.html.haml index eb57e8c55..056f9f23d 100644 --- a/app/views/start/_pro.html.haml +++ b/app/views/start/_pro.html.haml @@ -1,12 +1,9 @@ %p.lead{id: 'pro_section'} - %span{class:'text-info', style:'font-weight:bold'} - ='Si vous êtes un professionnel, ' - %p.lead - = form_tag(url_for({controller: :dossiers, action: :create}), class: 'form-inline', style: 'margin-top:10%', method: 'POST') do |f| + %h2#titre_procedure.text-info + Demande de subvention + %br + = form_tag(url_for({controller: :dossiers, action: :create}), class: 'form-inline', method: 'POST') do |f| .form-group.form-group-lg = text_field_tag :siret, nil, :class => "form-control", :placeholder => "Entrez votre Siret", :id => "siret", :name => "siret", :maxlength => 14, :style => 'margin-bottom:10px' %br - = number_field_tag :siret, nil, :class => "form-control", :placeholder => "Entrez n° de dossier", :id => "pro_dossier_id", :name => "pro_dossier_id", :style => 'display:none' - %a{:href => '#', :style => 'margin-top:10px', :id => 'btn_show_dossier_id_input', :onclick => 'show_dossier_id_input()'} J'ai un numéro de dossier - %br = submit_tag "Commencer", class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', data: { disable_with: "Commencer", submit: true} diff --git a/app/views/start/index.html.haml b/app/views/start/index.html.haml index 7f9248082..15bb0de56 100644 --- a/app/views/start/index.html.haml +++ b/app/views/start/index.html.haml @@ -1,13 +1,7 @@ .container.center %h1.cover-heading TéléProcédure administrative Simplifiée - %p + %br + %p{style: 'width:67%; margin-left:auto; margin-right:auto'} Site de démonstration d’un service public de saisie d’un projet ou de dépôt d’une démarche administrative, auprès d’un ou plusieurs organismes publics, simplifié des informations déjà connues des administrations, grâce à la fourniture du numéro SIRET. - .row{style:'margin-top:10%'} - -if !user_signed_in? - .col-lg-6.col-md-6 - = render partial: '/start/pro' - .col-lg-6.col-md-6.vr - = render partial: '/start/admin' - -else - .col-lg-12.col-md-12 - = render partial: '/start/admin' \ No newline at end of file + .row + = render partial: '/start/pro' diff --git a/spec/controllers/dossiers_controller_spec.rb b/spec/controllers/dossiers_controller_spec.rb index a16bd2e46..d8bb095cf 100644 --- a/spec/controllers/dossiers_controller_spec.rb +++ b/spec/controllers/dossiers_controller_spec.rb @@ -77,30 +77,30 @@ RSpec.describe DossiersController, type: :controller do end end end - context 'when pro_dossier_id is not empty' do - let!(:dossier) { create(:dossier, :with_entreprise) } - subject { post :create, siret: dossier.siret, pro_dossier_id: 99_999_999_999 } - - context 'when dossier not found' do - it 'redirects to start with error_dossier' do - expect(subject).to redirect_to(controller: :start, action: :error_dossier) - end - end - context 'when dossier found' do - context 'when siret match' do - subject { post :create, siret: dossier.siret, pro_dossier_id: dossier.id } - it 'redirects to controller recapitulatif' do - expect(subject).to redirect_to(controller: :recapitulatif, action: :show, dossier_id: dossier.id) - end - end - context 'when siret does not match' do - subject { post :create, siret: '11111111111111', pro_dossier_id: dossier.id } - it 'redirects to start with action error_dossier' do - expect(subject).to redirect_to(controller: :start, action: :error_dossier) - end - end - end - end + # context 'when pro_dossier_id is not empty' do + # let!(:dossier) { create(:dossier, :with_entreprise) } + # subject { post :create, siret: dossier.siret, pro_dossier_id: 99_999_999_999 } + # + # context 'when dossier not found' do + # it 'redirects to start with error_dossier' do + # expect(subject).to redirect_to(controller: :start, action: :error_dossier) + # end + # end + # context 'when dossier found' do + # context 'when siret match' do + # subject { post :create, siret: dossier.siret, pro_dossier_id: dossier.id } + # it 'redirects to controller recapitulatif' do + # expect(subject).to redirect_to(controller: :recapitulatif, action: :show, dossier_id: dossier.id) + # end + # end + # context 'when siret does not match' do + # subject { post :create, siret: '11111111111111', pro_dossier_id: dossier.id } + # it 'redirects to start with action error_dossier' do + # expect(subject).to redirect_to(controller: :start, action: :error_dossier) + # end + # end + # end + # end end end @@ -111,7 +111,7 @@ RSpec.describe DossiersController, type: :controller do context 'when Checkbox is checked' do let(:autorisation_donnees) { '1' } it 'redirects to demande' do - expect(response).to redirect_to(controller: :demandes, action: :show, dossier_id: dossier.id) + expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id) end it 'update dossier' do diff --git a/spec/features/dossiers_page/show_page_spec.rb b/spec/features/dossiers_page/show_page_spec.rb deleted file mode 100644 index 616704210..000000000 --- a/spec/features/dossiers_page/show_page_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'spec_helper' - -feature 'Dossier#Show Page' do - let(:dossier) { create(:dossier, :with_entreprise) } - - let(:dossier_id) { dossier.id } - - before do - visit "/dossiers/#{dossier_id}" - end - - context 'sur la page d\'information d\'un SIRET' do - scenario 'Le formulaire envoie vers /dossiers/:dossier_id en #POST' do - expect(page).to have_selector("form[action='/dossiers/#{dossier_id}'][method=post]") - end - - scenario 'la checkbox d\'information est présente' do - expect(page).to have_css('#dossier_autorisation_donnees') - end - - scenario 'le texte d\'information des droits est correct' do - expect(page).to have_content("J'autorise les organismes publics à vérifier les informations de mon entreprise auprès des administrations concernées. Ces informations resteront strictement confidentielles.") - end - - scenario 'les informations de l\'entreprise sont présents' do - expect(page).to have_content('Siret') - end - - scenario 'le bouton "Etape suivante" est présent' do - expect(page).to have_selector('#etape_suivante') - end - end -end diff --git a/spec/features/start_page/index_page_spec.rb b/spec/features/start_page/index_page_spec.rb deleted file mode 100644 index 65af9365e..000000000 --- a/spec/features/start_page/index_page_spec.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'spec_helper' - -feature 'Start#Index Page' do - context 'si personne n\'est connecté' do - before do - visit root_path - end - - scenario 'la section des professionnels est présente' do - expect(page).to have_selector('#pro_section') - end - - scenario 'la section des admin est présente' do - expect(page).to have_selector('#admin_section') - end - - context 'dans la section professionnel' do - scenario 'le formulaire envoie vers /dossiers en #POST' do - expect(page).to have_selector("form[action='/dossiers'][method=post]") - end - - scenario 'le champs "Numéro SIRET" est présent' do - expect(page).to have_selector('input[id=siret][name=siret]') - end - - scenario 'le champs "Numéro de dossier" n\'est pas visible' do - expect(page).to_not have_selector('input[id=pro_dossier_id][name=pro_dossier_id]') - end - - scenario 'button "j\'ai déjà un numéro de dossier "' do - expect(page).to have_selector('#btn_show_dossier_id_input') - end - - scenario 'le champs "Numéro SIRET" ne peut contenir que 15 caractères' do - length_string_20 = SecureRandom.hex(10) - find('#siret').set(length_string_20) - - expect(find('#siret').value.length).to eq(14) - end - end - - context 'dans la section admninistration' do - scenario 'le formulaire envoie vers /login en #POST' do - expect(page).to have_selector("form[action='/login'][method=post]") - end - - scenario ' le champs "Identifiant" est présent' do - expect(page).to have_selector("input[id=user_email][name='user[email]']") - end - - scenario 'le champs "Mot de passe" est présent' do - expect(page).to have_selector("input[id=user_password][name='user[password]']") - end - - scenario 'le champs "Mot de passe" est de type password' do - expect(page).to have_selector('input[type=password][id=user_password]') - end - - scenario 'le champs "Numéro de dossier" est présent' do - expect(page).to have_selector('input[id=dossier_id][name=dossier_id]') - end - end - end - - context 'si une administration est connecté' do - before do - login_admin - visit root_path - end - - scenario 'la section des professionnels n\'est pas présente' do - expect(page).to_not have_selector('#pro_section') - end - - scenario 'la section des admin est présente' do - expect(page).to have_selector('#admin_section') - end - - context 'dans la section admninistration' do - scenario 'le formulaire envoie vers /admin/dossiers en #GET' do - expect(page).to have_selector("form[action='/admin/dossiers'][method=get]") - end - - scenario ' le champs "Identifiant" n\'est pas présent' do - expect(page).to_not have_selector("input[id=user_email][name='user[email]']") - end - - scenario 'le champs "Mot de passe" n\'est pas présent' do - expect(page).to_not have_selector("input[id=user_password][name='user[password]']") - end - - scenario 'le champs "Numéro de dossier" est présent' do - expect(page).to have_selector('input[id=dossier_id][name=dossier_id]') - end - end - end -end diff --git a/spec/features/dossiers_page/_infos_dossier_spec.rb b/spec/views/dossiers/_infos_dossier_spec.rb similarity index 100% rename from spec/features/dossiers_page/_infos_dossier_spec.rb rename to spec/views/dossiers/_infos_dossier_spec.rb diff --git a/spec/features/dossiers_page/_infos_entreprise_spec.rb b/spec/views/dossiers/_infos_entreprise_spec.rb similarity index 100% rename from spec/features/dossiers_page/_infos_entreprise_spec.rb rename to spec/views/dossiers/_infos_entreprise_spec.rb diff --git a/spec/views/dossiers/show.html.haml_spec.rb b/spec/views/dossiers/show.html.haml_spec.rb index 6e1de9032..bd53a278a 100644 --- a/spec/views/dossiers/show.html.haml_spec.rb +++ b/spec/views/dossiers/show.html.haml_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' describe 'dossiers/show.html.haml', type: :view do let(:dossier) { create(:dossier, :with_entreprise) } + before do assign(:dossier, dossier) assign(:entreprise, dossier.entreprise.decorate) @@ -12,4 +13,26 @@ describe 'dossiers/show.html.haml', type: :view do it 'have autorisation_donnees check box' do expect(rendered).to have_css('#dossier_autorisation_donnees') end + + context 'sur la page d\'information d\'un SIRET' do + it 'Le formulaire envoie vers /dossiers/:dossier_id en #POST' do + expect(rendered).to have_selector("form[action='/dossiers/#{dossier.id}'][method=post]") + end + + it 'la checkbox d\'information est présente' do + expect(rendered).to have_css('#dossier_autorisation_donnees') + end + + it 'le texte d\'information des droits est correct' do + expect(rendered).to have_content("J'autorise les organismes publics à vérifier les informations de mon entreprise auprès des administrations concernées. Ces informations resteront strictement confidentielles.") + end + + it 'les informations de l\'entreprise sont présents' do + expect(rendered).to have_content('Siret') + end + + it 'le bouton "Etape suivante" est présent' do + expect(rendered).to have_selector('#etape_suivante') + end + end end diff --git a/spec/views/start/index.html.haml_spec.rb b/spec/views/start/index.html.haml_spec.rb new file mode 100644 index 000000000..69024f47d --- /dev/null +++ b/spec/views/start/index.html.haml_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe 'start/index.html.haml', type: :view do + context 'si personne n\'est connecté' do + before do + render + end + + it 'la section des professionnels est présente' do + expect(rendered).to have_selector('#pro_section') + end + + context 'dans la section professionnel' do + it 'le formulaire envoie vers /dossiers en #POST' do + expect(rendered).to have_selector("form[action='/dossiers'][method=post]") + end + + it 'le champs "Numéro SIRET" est présent' do + expect(rendered).to have_selector('input[id=siret][name=siret]') + end + + it 'le titre de la procédure' do + expect(rendered).to have_selector('#titre_procedure') + end + end + end +end \ No newline at end of file