diff --git a/app/controllers/dossiers_controller.rb b/app/controllers/dossiers_controller.rb
index 240400bcd..8f8ad60f1 100644
--- a/app/controllers/dossiers_controller.rb
+++ b/app/controllers/dossiers_controller.rb
@@ -1,73 +1,73 @@
class DossiersController < ApplicationController
- def show
- @dossier = Dossier.find(params[:id])
+ # def show
+ # @dossier = Dossier.find(params[:id])
- @etablissement = @dossier.etablissement
- @entreprise = @dossier.entreprise.decorate
- rescue ActiveRecord::RecordNotFound
- flash.alert = t('errors.messages.dossier_not_found')
- redirect_to url_for(controller: :siret)
- end
+ # @etablissement = @dossier.etablissement
+ # @entreprise = @dossier.entreprise.decorate
+ # rescue ActiveRecord::RecordNotFound
+ # flash.alert = t('errors.messages.dossier_not_found')
+ # redirect_to url_for(controller: :siret)
+ # end
- def create
- procedure = Procedure.find(params['procedure_id'])
- @etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
- @entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
- @dossier = Dossier.create
- @dossier.draft!
+ # def create
+ # procedure = Procedure.find(params['procedure_id'])
+ # @etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
+ # @entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
+ # @dossier = Dossier.create
+ # @dossier.draft!
- @dossier.procedure = procedure
- @dossier.save
+ # @dossier.procedure = procedure
+ # @dossier.save
- @entreprise.dossier = @dossier
- @entreprise.save
+ # @entreprise.dossier = @dossier
+ # @entreprise.save
- @etablissement.dossier = @dossier
- @etablissement.entreprise = @entreprise
- @etablissement.save
+ # @etablissement.dossier = @dossier
+ # @etablissement.entreprise = @entreprise
+ # @etablissement.save
- redirect_to url_for(controller: :dossiers, action: :show, id: @dossier.id)
+ # redirect_to url_for(controller: :dossiers, action: :show, id: @dossier.id)
- rescue RestClient::ResourceNotFound
- flash.alert = t('errors.messages.invalid_siret')
- redirect_to url_for(controller: :siret, procedure_id: params['procedure_id'])
- rescue ActiveRecord::RecordNotFound
- flash.alert = t('errors.messages.dossier_not_found')
- redirect_to url_for(controller: :siret)
- end
+ # rescue RestClient::ResourceNotFound
+ # flash.alert = t('errors.messages.invalid_siret')
+ # redirect_to url_for(controller: :siret, procedure_id: params['procedure_id'])
+ # rescue ActiveRecord::RecordNotFound
+ # flash.alert = t('errors.messages.dossier_not_found')
+ # redirect_to url_for(controller: :siret)
+ # end
- def update
- @dossier = Dossier.find(params[:id])
- if checked_autorisation_donnees?
- @dossier.update_attributes(update_params)
- redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id)
- else
- @etablissement = @dossier.etablissement
- @entreprise = @dossier.entreprise.decorate
- flash.now.alert = 'Les conditions sont obligatoires.'
- render 'show'
- end
- end
+ # def update
+ # @dossier = Dossier.find(params[:id])
+ # if checked_autorisation_donnees?
+ # @dossier.update_attributes(update_params)
+ # redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id)
+ # else
+ # @etablissement = @dossier.etablissement
+ # @entreprise = @dossier.entreprise.decorate
+ # flash.now.alert = 'Les conditions sont obligatoires.'
+ # render 'show'
+ # end
+ # end
- private
+ # private
- def update_params
- params.require(:dossier).permit(:autorisation_donnees)
- end
+ # def update_params
+ # params.require(:dossier).permit(:autorisation_donnees)
+ # end
- def dossier_id_is_present?
- @dossier_id != ''
- end
+ # def dossier_id_is_present?
+ # @dossier_id != ''
+ # end
- def checked_autorisation_donnees?
- update_params[:autorisation_donnees] == '1'
- end
+ # def checked_autorisation_donnees?
+ # update_params[:autorisation_donnees] == '1'
+ # end
- def siret
- params[:siret]
- end
+ # def siret
+ # params[:siret]
+ # end
- def siren
- siret[0..8]
- end
+ # def siren
+ # siret[0..8]
+ # end
end
diff --git a/app/controllers/users/commentaires_controller.rb b/app/controllers/users/commentaires_controller.rb
new file mode 100644
index 000000000..4c0ec854c
--- /dev/null
+++ b/app/controllers/users/commentaires_controller.rb
@@ -0,0 +1,3 @@
+class Users::CommentairesController < CommentairesController
+
+end
\ No newline at end of file
diff --git a/app/controllers/description_controller.rb b/app/controllers/users/description_controller.rb
similarity index 96%
rename from app/controllers/description_controller.rb
rename to app/controllers/users/description_controller.rb
index ba492d6b3..d952cab2d 100644
--- a/app/controllers/description_controller.rb
+++ b/app/controllers/users/description_controller.rb
@@ -1,4 +1,4 @@
-class DescriptionController < ApplicationController
+class Users::DescriptionController < ApplicationController
def show
@dossier = Dossier.find(params[:dossier_id])
@dossier = @dossier.decorate
diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb
index eaf68cfc4..808dca068 100644
--- a/app/controllers/users/dossiers_controller.rb
+++ b/app/controllers/users/dossiers_controller.rb
@@ -1,6 +1,79 @@
-class Users::DossiersController < ApplicationController
+class Users::DossiersController < UsersController
before_action :authenticate_user!
def index
@dossiers = Dossier.all.decorate
end
+ def show
+
+ @dossier = Dossier.find(params[:id])
+
+ @etablissement = @dossier.etablissement
+ @entreprise = @dossier.entreprise.decorate
+ rescue ActiveRecord::RecordNotFound
+ flash.alert = t('errors.messages.dossier_not_found')
+ redirect_to url_for(controller: :siret)
+ end
+
+ def create
+ procedure = Procedure.find(params['procedure_id'])
+ @etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
+ @entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
+ @dossier = Dossier.create
+ @dossier.draft!
+
+ @dossier.procedure = procedure
+ @dossier.save
+
+ @entreprise.dossier = @dossier
+ @entreprise.save
+
+ @etablissement.dossier = @dossier
+ @etablissement.entreprise = @entreprise
+ @etablissement.save
+
+ redirect_to url_for(controller: :dossiers, action: :show, id: @dossier.id)
+
+ rescue RestClient::ResourceNotFound
+ flash.alert = t('errors.messages.invalid_siret')
+ redirect_to url_for(controller: :siret, procedure_id: params['procedure_id'])
+ rescue ActiveRecord::RecordNotFound
+ flash.alert = t('errors.messages.dossier_not_found')
+ redirect_to url_for(controller: :siret)
+ end
+
+ def update
+
+ @dossier = Dossier.find(params[:id])
+ if checked_autorisation_donnees?
+ @dossier.update_attributes(update_params)
+ redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id)
+ else
+ @etablissement = @dossier.etablissement
+ @entreprise = @dossier.entreprise.decorate
+ flash.now.alert = 'Les conditions sont obligatoires.'
+ render 'show'
+ end
+ end
+
+ private
+
+ def update_params
+ params.require(:dossier).permit(:autorisation_donnees)
+ end
+
+ def dossier_id_is_present?
+ @dossier_id != ''
+ end
+
+ def checked_autorisation_donnees?
+ update_params[:autorisation_donnees] == '1'
+ end
+
+ def siret
+ params[:siret]
+ end
+
+ def siren
+ siret[0..8]
+ end
end
diff --git a/app/controllers/recapitulatif_controller.rb b/app/controllers/users/recapitulatif_controller.rb
similarity index 88%
rename from app/controllers/recapitulatif_controller.rb
rename to app/controllers/users/recapitulatif_controller.rb
index 4552dbc3b..2aa98ee6b 100644
--- a/app/controllers/recapitulatif_controller.rb
+++ b/app/controllers/users/recapitulatif_controller.rb
@@ -1,5 +1,6 @@
-class RecapitulatifController < ApplicationController
+class Users::RecapitulatifController < UsersController
def show
+
@dossier = Dossier.find(params[:dossier_id])
@dossier = @dossier.decorate
diff --git a/app/controllers/siret_controller.rb b/app/controllers/users/siret_controller.rb
similarity index 75%
rename from app/controllers/siret_controller.rb
rename to app/controllers/users/siret_controller.rb
index 5f5bb976f..99b861f27 100644
--- a/app/controllers/siret_controller.rb
+++ b/app/controllers/users/siret_controller.rb
@@ -1,5 +1,4 @@
-class SiretController < ApplicationController
- before_action :authenticate_user!
+class Users::SiretController < UsersController
def index
@procedure = Procedure.find(params['procedure_id'])
rescue ActiveRecord::RecordNotFound
@@ -9,5 +8,4 @@ class SiretController < ApplicationController
def error_procedure
render :file => "#{Rails.root}/public/404_procedure_not_found.html", :status => 404
end
-
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
new file mode 100644
index 000000000..32cb47327
--- /dev/null
+++ b/app/controllers/users_controller.rb
@@ -0,0 +1,3 @@
+class UsersController < ApplicationController
+ before_action :authenticate_user!
+end
\ No newline at end of file
diff --git a/app/views/backoffice/dossiers/show.html.haml b/app/views/backoffice/dossiers/show.html.haml
index 55c87ffb9..272893a45 100644
--- a/app/views/backoffice/dossiers/show.html.haml
+++ b/app/views/backoffice/dossiers/show.html.haml
@@ -44,7 +44,7 @@
= render partial: '/carte/carte_sources_JS_backend'
%br
-= render partial: '/recapitulatif/commentaires_flux'
+= render partial: '/users/recapitulatif/commentaires_flux'
%br
%br
diff --git a/app/views/dossiers/_show.html.haml b/app/views/dossiers/_show.html.haml
new file mode 100644
index 000000000..d8cff59a9
--- /dev/null
+++ b/app/views/dossiers/_show.html.haml
@@ -0,0 +1,13 @@
+.container#recap_info_entreprise
+ %h2 Récapitulatif de vos informations (récupérées auprès de l'INSEE et d'INFOGREFFE)
+ %br
+
+ %div.row
+ = render partial: '/dossiers/infos_entreprise'
+ %br
+ = form_for @dossier, url: { controller: '/users/dossiers', action: :create } do |f|
+ %label{ style:'font-weight:normal' }
+ = f.check_box :autorisation_donnees
+ J'autorise les organismes publics à vérifier les informations de mon entreprise auprès des administrations concernées. Ces informations resteront strictement confidentielles.
+ %br
+ = f.submit 'Etape suivante', class: "btn btn btn-info", style: 'float:right', id: 'etape_suivante'
\ No newline at end of file
diff --git a/app/views/dossiers/show.html.haml b/app/views/dossiers/show.html.haml
index 42262739c..74930f900 100644
--- a/app/views/dossiers/show.html.haml
+++ b/app/views/dossiers/show.html.haml
@@ -1,13 +1 @@
-.container#recap_info_entreprise
- %h2 Récapitulatif de vos informations (récupérées auprès de l'INSEE et d'INFOGREFFE)
- %br
-
- %div.row
- = render partial: 'infos_entreprise'
- %br
- = form_for @dossier do |f|
- %label{ style:'font-weight:normal' }
- = f.check_box :autorisation_donnees
- J'autorise les organismes publics à vérifier les informations de mon entreprise auprès des administrations concernées. Ces informations resteront strictement confidentielles.
- %br
- = f.submit 'Etape suivante', class: "btn btn btn-info", style: 'float:right', id: 'etape_suivante'
\ No newline at end of file
+= render partial: 'show'
\ No newline at end of file
diff --git a/app/views/siret/_admin.html.haml b/app/views/siret/_admin.html.haml
deleted file mode 100644
index 10a86bcc6..000000000
--- a/app/views/siret/_admin.html.haml
+++ /dev/null
@@ -1,24 +0,0 @@
-/ %p.lead{id: 'admin_section'}
-/ %span{class:'text-info', style:'font-weight:bold'}
-/ -if user_signed_in?
-/ ='Vous êtes identifié comme une administration'
-/ -else
-/ ='Si vous êtes une administration, '
-
-/ %p.lead
-/ -if user_signed_in?
-/ = form_tag(url_for({controller: 'admin/dossier', action: :index}), class: 'form-inline', method: 'GET') do
-/ .form-group.form-group-lg
-/ = text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "N° de dossier", :id => "dossier_id", :name => "dossier_id"
-/ %br
-/ = submit_tag "Accéder", class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', data: { disable_with: "Accéder", submit: true}
-/ -else
-/ = form_tag(url_for({controller: 'user/sessions', action: :create}), class: 'form-inline', method: 'POST') do
-/ .form-group.form-group-lg
-/ = text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "Identifiant", :id => "user_email", :name => "user[email]"
-/ %br
-/ = password_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "Mot de passe", :id => "user_password", :name => "user[password]"
-/ %br
-/ = text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "N° de dossier", :id => "dossier_id", :name => "dossier_id"
-/ %br
-/ = submit_tag "Accéder", class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', data: { disable_with: "Accéder", submit: true}
diff --git a/app/views/description/show.html.haml b/app/views/users/description/show.html.haml
similarity index 100%
rename from app/views/description/show.html.haml
rename to app/views/users/description/show.html.haml
diff --git a/app/views/users/dossiers/show.html.haml b/app/views/users/dossiers/show.html.haml
new file mode 100644
index 000000000..299da569b
--- /dev/null
+++ b/app/views/users/dossiers/show.html.haml
@@ -0,0 +1 @@
+= render partial: '/dossiers/show'
\ No newline at end of file
diff --git a/app/views/recapitulatif/_commentaires_flux.html.haml b/app/views/users/recapitulatif/_commentaires_flux.html.haml
similarity index 100%
rename from app/views/recapitulatif/_commentaires_flux.html.haml
rename to app/views/users/recapitulatif/_commentaires_flux.html.haml
diff --git a/app/views/recapitulatif/show.html.haml b/app/views/users/recapitulatif/show.html.haml
similarity index 100%
rename from app/views/recapitulatif/show.html.haml
rename to app/views/users/recapitulatif/show.html.haml
diff --git a/app/views/siret/_pro.html.haml b/app/views/users/siret/_pro.html.haml
similarity index 100%
rename from app/views/siret/_pro.html.haml
rename to app/views/users/siret/_pro.html.haml
diff --git a/app/views/siret/index.html.haml b/app/views/users/siret/index.html.haml
similarity index 92%
rename from app/views/siret/index.html.haml
rename to app/views/users/siret/index.html.haml
index 215baf74a..04e760ffc 100644
--- a/app/views/siret/index.html.haml
+++ b/app/views/users/siret/index.html.haml
@@ -5,5 +5,5 @@
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
- = render partial: '/siret/pro'
+ = render partial: 'pro'
diff --git a/config/routes.rb b/config/routes.rb
index d63e90db8..b444f1241 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,27 +12,39 @@ Rails.application.routes.draw do
# root 'welcome#index'
root 'users/dossiers#index'
- get 'siret' => 'siret#index'
+ namespace :users do
+ get 'siret' => 'siret#index'
+ resources :dossiers do
+ get '/description' => 'description#show'
+ get '/description/error' => 'description#error'
+ post 'description' => 'description#create'
+ get '/recapitulatif' => 'recapitulatif#show'
+ get '/demande' => 'demandes#show'
+ post '/demande' => 'demandes#update'
+ post '/commentaire' => 'commentaires#create'
+ end
+ resource :dossiers
-
- resources :dossiers do
- get '/demande' => 'demandes#show'
- post '/demande' => 'demandes#update'
-
- get '/carte/position' => 'carte#get_position'
- get '/carte' => 'carte#show'
- post '/carte' => 'carte#save_ref_api_carto'
-
- get '/description' => 'description#show'
- get '/description/error' => 'description#error'
- post 'description' => 'description#create'
-
- get '/recapitulatif' => 'recapitulatif#show'
-
- post '/commentaire' => 'commentaires#create'
end
+ # resources :dossiers do
+
+
+ # # get '/carte/position' => 'carte#get_position'
+ # # get '/carte' => 'carte#show'
+ # # post '/carte' => 'carte#save_ref_api_carto'
+
+ # # get '/description' => 'description#show'
+ # # get '/description/error' => 'description#error'
+ # # post 'description' => 'description#create'
+
+
+ # post '/commentaire' => 'commentaires#create'
+
+ # end
+
+
get 'backoffice' => 'backoffice#index'
namespace :backoffice do
diff --git a/spec/controllers/commentaires_controller_spec.rb b/spec/controllers/commentaires_controller_spec.rb
index 1bf28edec..2c25cc324 100644
--- a/spec/controllers/commentaires_controller_spec.rb
+++ b/spec/controllers/commentaires_controller_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe CommentairesController, type: :controller do
+describe Users::CommentairesController, type: :controller do
let(:dossier) { create(:dossier) }
let(:dossier_id) { dossier.id }
let(:email_commentaire) { 'test@test.com' }
@@ -10,7 +10,7 @@ describe CommentairesController, type: :controller do
context 'création correct d\'un commentaire' do
it 'depuis la page récapitulatif' do
post :create, dossier_id: dossier_id, email_commentaire: email_commentaire, texte_commentaire: texte_commentaire
- expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
+ expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
end
end
end
diff --git a/spec/controllers/description_controller_spec.rb b/spec/controllers/description_controller_spec.rb
index 1998f2258..30e15193e 100644
--- a/spec/controllers/description_controller_spec.rb
+++ b/spec/controllers/description_controller_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe DescriptionController, type: :controller do
+describe Users::DescriptionController, type: :controller do
let(:dossier) { create(:dossier, :with_procedure) }
let(:dossier_id) { dossier.id }
let(:bad_dossier_id) { Dossier.count + 10 }
@@ -37,7 +37,7 @@ describe DescriptionController, type: :controller do
# TODO separer en deux tests : check donnees et check redirect
it 'Premier enregistrement des données' do
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle
- expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
+ expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
end
# TODO changer les valeurs des champs et check in bdd
@@ -63,7 +63,7 @@ describe DescriptionController, type: :controller do
end
it 'Redirection vers la page récapitulatif' do
- expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
+ expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
end
end
end
diff --git a/spec/controllers/dossiers_controller_spec.rb b/spec/controllers/dossiers_controller_spec.rb
index 6c2f5d478..041b25c4f 100644
--- a/spec/controllers/dossiers_controller_spec.rb
+++ b/spec/controllers/dossiers_controller_spec.rb
@@ -1,124 +1,124 @@
require 'spec_helper'
describe DossiersController, type: :controller do
- let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
- let(:procedure) { create(:procedure) }
- let(:dossier_id) { dossier.id }
- let(:siret_not_found) { 999_999_999_999 }
+ # let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
+ # let(:procedure) { create(:procedure) }
+ # let(:dossier_id) { dossier.id }
+ # let(:siret_not_found) { 999_999_999_999 }
- let(:siren) { dossier.siren }
- let(:siret) { dossier.siret }
- let(:bad_siret) { 1 }
+ # let(:siren) { dossier.siren }
+ # let(:siret) { dossier.siret }
+ # let(:bad_siret) { 1 }
- describe 'GET #show' do
- it 'returns http success with dossier_id valid' do
- get :show, id: dossier_id
- expect(response).to have_http_status(:success)
- end
+ # describe 'GET #show' do
+ # it 'returns http success with dossier_id valid' do
+ # get :show, id: dossier_id
+ # expect(response).to have_http_status(:success)
+ # end
- it 'redirection vers siret si mauvais dossier ID' do
- get :show, id: siret_not_found
- expect(response).to redirect_to('/siret')
- end
- end
+ # it 'redirection vers siret si mauvais dossier ID' do
+ # get :show, id: siret_not_found
+ # expect(response).to redirect_to('/siret')
+ # end
+ # end
- describe 'POST #create' do
- before do
- stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
- .to_return(status: 404, body: 'fake body')
+ # describe 'POST #create' do
+ # before do
+ # stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
+ # .to_return(status: 404, body: 'fake body')
- stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
- .to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
+ # stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
+ # .to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
- stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
- .to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
- end
+ # stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
+ # .to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
+ # end
- describe 'professionnel fills form' do
- context 'when pro_dossier_id is empty' do
- context 'with valid siret ' do
+ # describe 'professionnel fills form' do
+ # context 'when pro_dossier_id is empty' do
+ # context 'with valid siret ' do
- subject { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }
+ # subject { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }
- it 'create a dossier' do
- expect { subject }.to change { Dossier.count }.by(1)
- end
+ # it 'create a dossier' do
+ # expect { subject }.to change { Dossier.count }.by(1)
+ # end
- it 'creates entreprise' do
- expect { subject }.to change { Entreprise.count }.by(1)
- end
+ # it 'creates entreprise' do
+ # expect { subject }.to change { Entreprise.count }.by(1)
+ # end
- it 'links entreprise to dossier' do
- expect(Entreprise.last.dossier).to eq(Dossier.last)
- end
+ # it 'links entreprise to dossier' do
+ # expect(Entreprise.last.dossier).to eq(Dossier.last)
+ # end
- it 'creates etablissement for dossier' do
- expect { subject }.to change { Etablissement.count }.by(1)
- end
+ # it 'creates etablissement for dossier' do
+ # expect { subject }.to change { Etablissement.count }.by(1)
+ # end
- it 'links etablissement to dossier' do
- subject
- expect(Etablissement.last.dossier).to eq(Dossier.last)
- end
+ # it 'links etablissement to dossier' do
+ # subject
+ # expect(Etablissement.last.dossier).to eq(Dossier.last)
+ # end
- it 'links etablissement to entreprise' do
- subject
- expect(Etablissement.last.entreprise).to eq(Entreprise.last)
- end
+ # it 'links etablissement to entreprise' do
+ # subject
+ # expect(Etablissement.last.entreprise).to eq(Entreprise.last)
+ # end
- it 'links procedure to dossier' do
- subject
- expect(Dossier.last.procedure).to eq(Procedure.last)
- end
+ # it 'links procedure to dossier' do
+ # subject
+ # expect(Dossier.last.procedure).to eq(Procedure.last)
+ # end
- it 'state of dossier is draft' do
- subject
- expect(Dossier.last.state).to eq('draft')
- end
- end
+ # it 'state of dossier is draft' do
+ # subject
+ # expect(Dossier.last.state).to eq('draft')
+ # end
+ # end
- context 'with non existant siret' do
- let(:siret_not_found) { '11111111111111' }
- subject { post :create, siret: siret_not_found, pro_dossier_id: '', procedure_id: procedure.id }
- it 'does not create new dossier' do
- expect { subject }.not_to change { Dossier.count }
- end
+ # context 'with non existant siret' do
+ # let(:siret_not_found) { '11111111111111' }
+ # subject { post :create, siret: siret_not_found, pro_dossier_id: '', procedure_id: procedure.id }
+ # it 'does not create new dossier' do
+ # expect { subject }.not_to change { Dossier.count }
+ # end
- it 'redirects to show' do
- expect(subject).to redirect_to(controller: :siret, procedure_id: procedure.id)
- end
- end
- end
- end
- end
+ # it 'redirects to show' do
+ # expect(subject).to redirect_to(controller: :siret, procedure_id: procedure.id)
+ # end
+ # end
+ # end
+ # end
+ # end
- describe 'PUT #update' do
- before do
- put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
- end
- context 'when Checkbox is checked' do
- let(:autorisation_donnees) { '1' }
- it 'redirects to demande' do
- expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id)
- end
+ # describe 'PUT #update' do
+ # before do
+ # put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
+ # end
+ # context 'when Checkbox is checked' do
+ # let(:autorisation_donnees) { '1' }
+ # it 'redirects to demande' do
+ # expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id)
+ # end
- it 'update dossier' do
- dossier.reload
- expect(dossier.autorisation_donnees).to be_truthy
- end
- end
+ # it 'update dossier' do
+ # dossier.reload
+ # expect(dossier.autorisation_donnees).to be_truthy
+ # end
+ # end
- context 'when Checkbox is not checked' do
- let(:autorisation_donnees) { '0' }
- it 'uses flash alert to display message' do
- expect(flash[:alert]).to have_content('Les conditions sont obligatoires.')
- end
+ # context 'when Checkbox is not checked' do
+ # let(:autorisation_donnees) { '0' }
+ # it 'uses flash alert to display message' do
+ # expect(flash[:alert]).to have_content('Les conditions sont obligatoires.')
+ # end
- it "doesn't update dossier autorisation_donnees" do
- dossier.reload
- expect(dossier.autorisation_donnees).to be_falsy
- end
- end
- end
+ # it "doesn't update dossier autorisation_donnees" do
+ # dossier.reload
+ # expect(dossier.autorisation_donnees).to be_falsy
+ # end
+ # end
+ # end
end
diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb
index 6a136ab38..ac6083304 100644
--- a/spec/controllers/users/dossiers_controller_spec.rb
+++ b/spec/controllers/users/dossiers_controller_spec.rb
@@ -14,4 +14,135 @@ describe Users::DossiersController, type: :controller do
it { is_expected.to have_http_status(:success) }
end
end
+ let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
+ let(:procedure) { create(:procedure) }
+ let(:dossier_id) { dossier.id }
+ let(:siret_not_found) { 999_999_999_999 }
+
+ let(:siren) { dossier.siren }
+ let(:siret) { dossier.siret }
+ let(:bad_siret) { 1 }
+
+ describe 'GET #show' do
+ before do
+ sign_in create(:user)
+ end
+ it 'returns http success with dossier_id valid' do
+ get :show, id: dossier_id
+ expect(response).to have_http_status(:success)
+ end
+
+ it 'redirection vers siret si mauvais dossier ID' do
+ get :show, id: siret_not_found
+ expect(response).to redirect_to('/users/siret')
+ end
+ end
+
+ describe 'POST #create' do
+ before do
+ stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
+ .to_return(status: 404, body: 'fake body')
+
+ stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
+ .to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
+
+ stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
+ .to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
+ end
+
+ describe 'professionnel fills form' do
+ context 'when pro_dossier_id is empty' do
+ context 'with valid siret ' do
+ before do
+ sign_in create(:user)
+ end
+
+ subject { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }
+
+
+ it 'create a dossier' do
+ expect { subject }.to change { Dossier.count }.by(1)
+ end
+
+ it 'creates entreprise' do
+ expect { subject }.to change { Entreprise.count }.by(1)
+ end
+
+ it 'links entreprise to dossier' do
+ expect(Entreprise.last.dossier).to eq(Dossier.last)
+ end
+
+ it 'creates etablissement for dossier' do
+ expect { subject }.to change { Etablissement.count }.by(1)
+ end
+
+ it 'links etablissement to dossier' do
+ subject
+ expect(Etablissement.last.dossier).to eq(Dossier.last)
+ end
+
+ it 'links etablissement to entreprise' do
+ subject
+ expect(Etablissement.last.entreprise).to eq(Entreprise.last)
+ end
+
+ it 'links procedure to dossier' do
+ subject
+ expect(Dossier.last.procedure).to eq(Procedure.last)
+ end
+
+ it 'state of dossier is draft' do
+ subject
+ expect(Dossier.last.state).to eq('draft')
+ end
+ end
+
+ context 'with non existant siret' do
+ before do
+ sign_in create(:user)
+ end
+
+ let(:siret_not_found) { '11111111111111' }
+ subject { post :create, siret: siret_not_found, pro_dossier_id: '', procedure_id: procedure.id }
+ it 'does not create new dossier' do
+ expect { subject }.not_to change { Dossier.count }
+ end
+
+ it 'redirects to show' do
+ expect(subject).to redirect_to(controller: :siret, procedure_id: procedure.id)
+ end
+ end
+ end
+ end
+ end
+
+ describe 'PUT #update' do
+ before do
+ sign_in create(:user)
+ put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
+ end
+ context 'when Checkbox is checked' do
+ let(:autorisation_donnees) { '1' }
+ it 'redirects to demande' do
+ expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id)
+ end
+
+ it 'update dossier' do
+ dossier.reload
+ expect(dossier.autorisation_donnees).to be_truthy
+ end
+ end
+
+ context 'when Checkbox is not checked' do
+ let(:autorisation_donnees) { '0' }
+ it 'uses flash alert to display message' do
+ expect(flash[:alert]).to have_content('Les conditions sont obligatoires.')
+ end
+
+ it "doesn't update dossier autorisation_donnees" do
+ dossier.reload
+ expect(dossier.autorisation_donnees).to be_falsy
+ end
+ end
+ end
end
\ No newline at end of file
diff --git a/spec/controllers/recapitulatif_controller_spec.rb b/spec/controllers/users/recapitulatif_controller_spec.rb
similarity index 53%
rename from spec/controllers/recapitulatif_controller_spec.rb
rename to spec/controllers/users/recapitulatif_controller_spec.rb
index 1d572121a..e40e48804 100644
--- a/spec/controllers/recapitulatif_controller_spec.rb
+++ b/spec/controllers/users/recapitulatif_controller_spec.rb
@@ -1,11 +1,14 @@
require 'spec_helper'
-RSpec.describe RecapitulatifController, type: :controller do
- let(:dossier) { create(:dossier) }
+describe Users::RecapitulatifController, type: :controller do
+ let(:dossier) { create(:dossier, :with_user) }
- let(:bad_dossier_id) { Dossier.count + 10 }
+ let(:bad_dossier_id) { Dossier.count + 100000 }
describe 'GET #show' do
+ before do
+ sign_in dossier.user
+ end
it 'returns http success' do
get :show, dossier_id: dossier.id
expect(response).to have_http_status(:success)
@@ -13,7 +16,7 @@ RSpec.describe RecapitulatifController, type: :controller do
it 'redirection vers siret si mauvais dossier ID' do
get :show, dossier_id: bad_dossier_id
- expect(response).to redirect_to('/siret')
+ expect(response).to redirect_to('/users/siret')
end
end
end
diff --git a/spec/controllers/siret_controller_spec.rb b/spec/controllers/users/siret_controller_spec.rb
similarity index 97%
rename from spec/controllers/siret_controller_spec.rb
rename to spec/controllers/users/siret_controller_spec.rb
index e169a8fd7..cf6b48151 100644
--- a/spec/controllers/siret_controller_spec.rb
+++ b/spec/controllers/users/siret_controller_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe SiretController, type: :controller do
+describe Users::SiretController, type: :controller do
let!(:procedure) { create(:procedure) }
describe 'GET #index' do
diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb
index 06fb0057b..239fec250 100644
--- a/spec/factories/dossier.rb
+++ b/spec/factories/dossier.rb
@@ -16,5 +16,11 @@ FactoryGirl.define do
dossier.procedure = procedure
end
end
+
+ trait :with_user do
+ after(:build) do |dossier, _evaluator|
+ dossier.user = create(:user)
+ end
+ end
end
end
diff --git a/spec/features/datepicker_spec.rb b/spec/features/datepicker_spec.rb
index 46f23c817..c0643a79f 100644
--- a/spec/features/datepicker_spec.rb
+++ b/spec/features/datepicker_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
feature 'On the description page' do
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
before do
- visit dossier_description_path dossier
+ visit users_dossier_description_path dossier
end
scenario 'date_previsionnelle field is present' do
expect(page).to have_css('#date_previsionnelle')
diff --git a/spec/features/description_page/show_page_spec.rb b/spec/features/description_page/show_page_spec.rb
index 226db6a9a..132783c21 100644
--- a/spec/features/description_page/show_page_spec.rb
+++ b/spec/features/description_page/show_page_spec.rb
@@ -5,12 +5,12 @@ feature 'Description#Show Page' do
let(:dossier_id) { dossier.id }
before do
- visit "/dossiers/#{dossier_id}/description"
+ visit users_dossier_description_path(dossier_id: dossier_id)
end
context 'tous les attributs sont présents sur la page' do
- scenario 'Le formulaire envoie vers /dossiers/:dossier_id/description en #POST' do
- expect(page).to have_selector("form[action='/dossiers/#{dossier_id}/description'][method=post]")
+ scenario 'Le formulaire envoie vers /users/dossiers/:dossier_id/description en #POST' do
+ expect(page).to have_selector("form[action='/users/dossiers/#{dossier_id}/description'][method=post]")
end
scenario 'Nom du projet' do
@@ -62,7 +62,7 @@ feature 'Description#Show Page' do
context 'si la page précédente est recapitularif' do
before do
- visit "/dossiers/#{dossier_id}/description?back_url=recapitulatif"
+ visit "/users/dossiers/#{dossier_id}/description?back_url=recapitulatif"
end
scenario 'le bouton "Terminer" n\'est pas présent' do
diff --git a/spec/features/description_page/upload_piece_justificative_spec.rb b/spec/features/description_page/upload_piece_justificative_spec.rb
index 92ad922cc..d0333658c 100644
--- a/spec/features/description_page/upload_piece_justificative_spec.rb
+++ b/spec/features/description_page/upload_piece_justificative_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
feature 'user is on description page' do
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
before do
- visit dossier_description_path dossier
+ visit users_dossier_description_path dossier
end
it { expect(page).to have_css('#description_page') }
diff --git a/spec/features/recapitulatif_page/_commentaires_flux_spec.rb b/spec/features/recapitulatif_page/_commentaires_flux_spec.rb
index 273fa990b..a50437a0c 100644
--- a/spec/features/recapitulatif_page/_commentaires_flux_spec.rb
+++ b/spec/features/recapitulatif_page/_commentaires_flux_spec.rb
@@ -1,19 +1,20 @@
require 'spec_helper'
feature '_Commentaires_Flux Recapitulatif#Show Page' do
- let(:dossier) { create(:dossier) }
+ let(:dossier) { create(:dossier, :with_user) }
let(:dossier_id) { dossier.id }
let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' }
let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description') }
let(:body) { 'Commentaire de test' }
before do
- visit "/dossiers/#{dossier_id}/recapitulatif"
+ login_as(dossier.user, scope: :user)
+ visit "/users/dossiers/#{dossier_id}/recapitulatif"
end
context 'Affichage du flux de commentaire' do
scenario 'l\'email du contact est présent' do
- expect(page).to have_selector('span[id=email_contact]')
+ expect(page).to have_css('#email_contact')
end
scenario 'la date du commentaire est présent' do
@@ -21,13 +22,13 @@ feature '_Commentaires_Flux Recapitulatif#Show Page' do
end
scenario 'le corps du commentaire est présent' do
- expect(page).to have_selector('div[class=description][id=body]')
+ expect(page).to have_css('.description#body')
end
end
context 'Affichage du formulaire de commentaire' do
scenario 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do
- expect(page).to have_selector("form[action='/dossiers/#{dossier_id}/commentaire'][method=post]")
+ expect(page).to have_selector("form[action='/users/dossiers/#{dossier_id}/commentaire'][method=post]")
end
scenario 'Champs de texte' do
diff --git a/spec/features/recapitulatif_page/show_page_spec.rb b/spec/features/recapitulatif_page/show_page_spec.rb
index f5959a26d..2b0d739c5 100644
--- a/spec/features/recapitulatif_page/show_page_spec.rb
+++ b/spec/features/recapitulatif_page/show_page_spec.rb
@@ -1,12 +1,13 @@
require 'spec_helper'
feature 'Recapitulatif#Show Page' do
- let(:dossier) { create(:dossier) }
+ let(:dossier) { create(:dossier, :with_user) }
let(:dossier_id) { dossier.id }
before do
Capybara.current_session.driver.header('Referer', '/description')
- visit "/dossiers/#{dossier_id}/recapitulatif"
+ login_as(dossier.user, :scope => :user)
+ visit "/users/dossiers/#{dossier_id}/recapitulatif"
end
context 'sur la page recapitulative' do
@@ -42,14 +43,14 @@ feature 'Recapitulatif#Show Page' do
scenario 'N\'est pas affiché quand l\'on vient d\'une autre la page que description' do
Capybara.current_session.driver.header('Referer', '/')
- visit "/dossiers/#{dossier_id}/recapitulatif"
+ visit "/users/dossiers/#{dossier_id}/recapitulatif"
expect(page).to_not have_content('Félicitation')
end
scenario 'N\'est pas affiché quand l\'on vient de la page description en modification' do
Capybara.current_session.driver.header('Referer', '/description?back_url=recapitulatif')
- visit "/dossiers/#{dossier_id}/recapitulatif"
+ visit "/users/dossiers/#{dossier_id}/recapitulatif"
expect(page).to_not have_content('Félicitation')
end
diff --git a/spec/features/users/start_demande_spec.rb b/spec/features/users/start_demande_spec.rb
index 1da39fcc2..b1ac18d06 100644
--- a/spec/features/users/start_demande_spec.rb
+++ b/spec/features/users/start_demande_spec.rb
@@ -7,7 +7,7 @@ feature 'user arrive on siret page' do
let(:siren) { siret[0...9] }
context 'when user is not logged in' do
before do
- visit siret_path(procedure_id: procedure.id)
+ visit users_siret_path(procedure_id: procedure.id)
end
scenario 'he is redirected to login page' do
expect(page).to have_css('#login_user')
diff --git a/spec/views/dossiers/show.html.haml_spec.rb b/spec/views/dossiers/show.html.haml_spec.rb
index bd53a278a..c5820f8d7 100644
--- a/spec/views/dossiers/show.html.haml_spec.rb
+++ b/spec/views/dossiers/show.html.haml_spec.rb
@@ -14,20 +14,20 @@ describe 'dossiers/show.html.haml', type: :view 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]")
+ context "sur la page d'information d'un SIRET" do
+ it 'Le formulaire envoie vers /users/dossiers/:dossier_id en #POST' do
+ expect(rendered).to have_selector("form[action='/users/dossiers'][method=post]")
end
- it 'la checkbox d\'information est présente' do
+ 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
+ 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
+ it "les informations de l'entreprise sont présents" do
expect(rendered).to have_content('Siret')
end
diff --git a/spec/views/siret/index.html.haml_spec.rb b/spec/views/users/siret/index.html.haml_spec.rb
similarity index 87%
rename from spec/views/siret/index.html.haml_spec.rb
rename to spec/views/users/siret/index.html.haml_spec.rb
index 9d27ae043..5740ac7af 100644
--- a/spec/views/siret/index.html.haml_spec.rb
+++ b/spec/views/users/siret/index.html.haml_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'siret/index.html.haml', type: :view do
+describe 'users/siret/index.html.haml', type: :view do
let(:procedure) { create(:procedure, libelle: 'Demande de subvention') }
before do
assign(:procedure, procedure)
@@ -13,7 +13,7 @@ describe 'siret/index.html.haml', type: :view do
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]")
+ expect(rendered).to have_selector("form[action='/users/dossiers'][method=post]")
end
it 'le champs "Numéro SIRET" est présent' do