diff --git a/Gemfile b/Gemfile
index 7fe3f3a66..47c9b9fac 100644
--- a/Gemfile
+++ b/Gemfile
@@ -59,6 +59,8 @@ gem 'chartkick'
gem 'logstasher'
+gem "font-awesome-rails"
+
group :test do
gem 'capybara'
gem 'factory_girl'
diff --git a/Gemfile.lock b/Gemfile.lock
index 6db37841d..c1ca792c0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -114,6 +114,8 @@ GEM
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
ffi (1.9.6)
+ font-awesome-rails (4.4.0.0)
+ railties (>= 3.2, < 5.0)
globalid (0.3.5)
activesupport (>= 4.1.0)
haml (4.0.6)
@@ -339,6 +341,7 @@ DEPENDENCIES
devise
draper
factory_girl
+ font-awesome-rails
haml-rails
jbuilder (~> 2.0)
jquery-rails
@@ -372,3 +375,6 @@ DEPENDENCIES
unicorn
web-console (~> 2.0)
webmock
+
+BUNDLED WITH
+ 1.10.4
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index 12918330d..fba78480c 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -16,6 +16,7 @@
*= require_self
*= require bootstrap-datepicker3
*= require leaflet
+ *= require font-awesome
*/
@import "bootstrap-sprockets";
@import "bootstrap";
diff --git a/app/assets/stylesheets/start.scss b/app/assets/stylesheets/siret.scss
similarity index 100%
rename from app/assets/stylesheets/start.scss
rename to app/assets/stylesheets/siret.scss
diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb
index 189cbab65..e1f4c96ec 100644
--- a/app/controllers/backoffice/dossiers_controller.rb
+++ b/app/controllers/backoffice/dossiers_controller.rb
@@ -14,12 +14,8 @@ class Backoffice::DossiersController < ApplicationController
@dossier = @dossier.decorate
rescue ActiveRecord::RecordNotFound
- redirect_start
+ flash.alert = t('errors.messages.dossier_not_found')
+ redirect_to url_for(controller: '/backoffice')
end
- private
-
- def redirect_start
- redirect_to url_for(controller: '/start', action: :error_dossier)
- end
end
diff --git a/app/controllers/carte_controller.rb b/app/controllers/carte_controller.rb
index d36f24d14..2e11af799 100644
--- a/app/controllers/carte_controller.rb
+++ b/app/controllers/carte_controller.rb
@@ -4,7 +4,7 @@ class CarteController < ApplicationController
def show
@dossier = current_dossier
rescue ActiveRecord::RecordNotFound
- redirect_to url_for(controller: :start, action: :error_dossier)
+ redirect_to url_for(controller: :siret, action: :error_dossier)
end
def save_ref_api_carto
diff --git a/app/controllers/dossiers_controller.rb b/app/controllers/dossiers_controller.rb
index 07e27a368..8f8ad60f1 100644
--- a/app/controllers/dossiers_controller.rb
+++ b/app/controllers/dossiers_controller.rb
@@ -1,69 +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
- redirect_to url_for(controller: :start, action: :error_dossier)
- 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
- @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.find(params['procedure_id'])
- @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
- redirect_to url_for(controller: :start, action: :error_siret, procedure_id: params['procedure_id'])
- rescue ActiveRecord::RecordNotFound
- redirect_to url_for(controller: :start, action: :error_dossier)
- 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/start_controller.rb b/app/controllers/start_controller.rb
deleted file mode 100644
index 87cbd34fa..000000000
--- a/app/controllers/start_controller.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-class StartController < ApplicationController
- def index
- get_procedure_infos
-
- if @procedure.nil?
- error_procedure
- end
- rescue ActiveRecord::RecordNotFound
- error_procedure
- end
-
- def error_procedure
- render :file => "#{Rails.root}/public/404_procedure_not_found.html", :status => 404
- end
-
- def error_siret
- get_procedure_infos
- flash.now.alert = 'Ce SIRET n\'est pas valide'
- render 'index'
- end
-
- def error_login
- flash.now.alert = 'Ce compte n\'existe pas'
- render 'index'
- end
-
- def error_dossier
- flash.now.alert = 'Ce dossier n\'existe pas'
- render 'index'
- end
-
- private
-
- def get_procedure_infos
- @procedure = Procedure.find(params['procedure_id'])
- 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/users/confirmations_controller.rb b/app/controllers/users/confirmations_controller.rb
new file mode 100644
index 000000000..1126e23aa
--- /dev/null
+++ b/app/controllers/users/confirmations_controller.rb
@@ -0,0 +1,28 @@
+class Users::ConfirmationsController < Devise::ConfirmationsController
+ # GET /resource/confirmation/new
+ # def new
+ # super
+ # end
+
+ # POST /resource/confirmation
+ # def create
+ # super
+ # end
+
+ # GET /resource/confirmation?confirmation_token=abcdef
+ # def show
+ # super
+ # end
+
+ # protected
+
+ # The path used after resending confirmation instructions.
+ # def after_resending_confirmation_instructions_path_for(resource_name)
+ # super(resource_name)
+ # end
+
+ # The path used after confirmation.
+ # def after_confirmation_path_for(resource_name, resource)
+ # super(resource_name, resource)
+ # end
+end
diff --git a/app/controllers/description_controller.rb b/app/controllers/users/description_controller.rb
similarity index 91%
rename from app/controllers/description_controller.rb
rename to app/controllers/users/description_controller.rb
index 7835f1e00..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
@@ -6,7 +6,8 @@ class DescriptionController < ApplicationController
@procedure = @dossier.procedure
rescue ActiveRecord::RecordNotFound
- redirect_to url_for(controller: :start, action: :error_dossier)
+ flash.alert = t('errors.messages.dossier_not_found')
+ redirect_to url_for(controller: :siret)
end
def error
diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb
new file mode 100644
index 000000000..808dca068
--- /dev/null
+++ b/app/controllers/users/dossiers_controller.rb
@@ -0,0 +1,79 @@
+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/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb
new file mode 100644
index 000000000..6e98c15d1
--- /dev/null
+++ b/app/controllers/users/omniauth_callbacks_controller.rb
@@ -0,0 +1,28 @@
+class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
+ # You should configure your model like this:
+ # devise :omniauthable, omniauth_providers: [:twitter]
+
+ # You should also create an action method in this controller like this:
+ # def twitter
+ # end
+
+ # More info at:
+ # https://github.com/plataformatec/devise#omniauth
+
+ # GET|POST /resource/auth/twitter
+ # def passthru
+ # super
+ # end
+
+ # GET|POST /users/auth/twitter/callback
+ # def failure
+ # super
+ # end
+
+ # protected
+
+ # The path used when omniauth fails
+ # def after_omniauth_failure_path_for(scope)
+ # super(scope)
+ # end
+end
diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb
new file mode 100644
index 000000000..53cc34e39
--- /dev/null
+++ b/app/controllers/users/passwords_controller.rb
@@ -0,0 +1,32 @@
+class Users::PasswordsController < Devise::PasswordsController
+ # GET /resource/password/new
+ # def new
+ # super
+ # end
+
+ # POST /resource/password
+ # def create
+ # super
+ # end
+
+ # GET /resource/password/edit?reset_password_token=abcdef
+ # def edit
+ # super
+ # end
+
+ # PUT /resource/password
+ # def update
+ # super
+ # end
+
+ # protected
+
+ # def after_resetting_password_path_for(resource)
+ # super(resource)
+ # end
+
+ # The path used after sending reset password instructions
+ # def after_sending_reset_password_instructions_path_for(resource_name)
+ # super(resource_name)
+ # end
+end
diff --git a/app/controllers/recapitulatif_controller.rb b/app/controllers/users/recapitulatif_controller.rb
similarity index 71%
rename from app/controllers/recapitulatif_controller.rb
rename to app/controllers/users/recapitulatif_controller.rb
index 23507f618..187deda39 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
@procedure = @dossier.procedure
@@ -12,6 +13,7 @@ class RecapitulatifController < ApplicationController
#TODO load user email
@commentaire_email = 'user@email'
rescue ActiveRecord::RecordNotFound
- redirect_to url_for(controller: :start, action: :error_dossier)
+ flash.alert = t('errors.messages.dossier_not_found')
+ redirect_to url_for(controller: :siret)
end
end
diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb
new file mode 100644
index 000000000..41c3a9002
--- /dev/null
+++ b/app/controllers/users/registrations_controller.rb
@@ -0,0 +1,60 @@
+class Users::RegistrationsController < Devise::RegistrationsController
+# before_filter :configure_sign_up_params, only: [:create]
+# before_filter :configure_account_update_params, only: [:update]
+
+ # GET /resource/sign_up
+ # def new
+ # super
+ # end
+
+ # POST /resource
+ # def create
+ # super
+ # end
+
+ # GET /resource/edit
+ # def edit
+ # super
+ # end
+
+ # PUT /resource
+ # def update
+ # super
+ # end
+
+ # DELETE /resource
+ # def destroy
+ # super
+ # end
+
+ # GET /resource/cancel
+ # Forces the session data which is usually expired after sign
+ # in to be expired now. This is useful if the user wants to
+ # cancel oauth signing in/up in the middle of the process,
+ # removing all OAuth session data.
+ # def cancel
+ # super
+ # end
+
+ # protected
+
+ # You can put the params you want to permit in the empty array.
+ # def configure_sign_up_params
+ # devise_parameter_sanitizer.for(:sign_up) << :attribute
+ # end
+
+ # You can put the params you want to permit in the empty array.
+ # def configure_account_update_params
+ # devise_parameter_sanitizer.for(:account_update) << :attribute
+ # end
+
+ # The path used after sign up.
+ # def after_sign_up_path_for(resource)
+ # super(resource)
+ # end
+
+ # The path used after sign up for inactive accounts.
+ # def after_inactive_sign_up_path_for(resource)
+ # super(resource)
+ # end
+end
diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb
new file mode 100644
index 000000000..45bf9e8e2
--- /dev/null
+++ b/app/controllers/users/sessions_controller.rb
@@ -0,0 +1,25 @@
+class Users::SessionsController < Devise::SessionsController
+# before_filter :configure_sign_in_params, only: [:create]
+
+ # GET /resource/sign_in
+ # def new
+ # super
+ # end
+
+ # POST /resource/sign_in
+ # def create
+ # super
+ # end
+
+ # DELETE /resource/sign_out
+ # def destroy
+ # super
+ # end
+
+ # protected
+
+ # You can put the params you want to permit in the empty array.
+ # def configure_sign_in_params
+ # devise_parameter_sanitizer.for(:sign_in) << :attribute
+ # end
+end
diff --git a/app/controllers/users/siret_controller.rb b/app/controllers/users/siret_controller.rb
new file mode 100644
index 000000000..99b861f27
--- /dev/null
+++ b/app/controllers/users/siret_controller.rb
@@ -0,0 +1,11 @@
+class Users::SiretController < UsersController
+ def index
+ @procedure = Procedure.find(params['procedure_id'])
+ rescue ActiveRecord::RecordNotFound
+ error_procedure
+ end
+
+ def error_procedure
+ render :file => "#{Rails.root}/public/404_procedure_not_found.html", :status => 404
+ end
+end
diff --git a/app/controllers/users/unlocks_controller.rb b/app/controllers/users/unlocks_controller.rb
new file mode 100644
index 000000000..8b9ef8612
--- /dev/null
+++ b/app/controllers/users/unlocks_controller.rb
@@ -0,0 +1,28 @@
+class Users::UnlocksController < Devise::UnlocksController
+ # GET /resource/unlock/new
+ # def new
+ # super
+ # end
+
+ # POST /resource/unlock
+ # def create
+ # super
+ # end
+
+ # GET /resource/unlock?unlock_token=abcdef
+ # def show
+ # super
+ # end
+
+ # protected
+
+ # The path used after sending unlock password instructions
+ # def after_sending_unlock_instructions_path_for(resource)
+ # super(resource)
+ # end
+
+ # The path used after unlocking the resource
+ # def after_unlock_path_for(resource)
+ # super(resource)
+ # 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/models/dossier.rb b/app/models/dossier.rb
index 94518ee01..1c0de210e 100644
--- a/app/models/dossier.rb
+++ b/app/models/dossier.rb
@@ -12,6 +12,7 @@ class Dossier < ActiveRecord::Base
has_one :cerfa
has_many :pieces_justificatives
belongs_to :procedure
+ belongs_to :user
has_many :commentaires
delegate :siren, to: :entreprise
diff --git a/app/models/user.rb b/app/models/user.rb
new file mode 100644
index 000000000..802edb08c
--- /dev/null
+++ b/app/models/user.rb
@@ -0,0 +1,8 @@
+class User < ActiveRecord::Base
+ # Include default devise modules. Others available are:
+ # :confirmable, :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable, :registerable,
+ :recoverable, :rememberable, :trackable, :validatable
+
+ has_many :dossiers
+end
diff --git a/app/views/backoffice/dossiers/show.html.haml b/app/views/backoffice/dossiers/show.html.haml
index 66ca14431..628d642e2 100644
--- a/app/views/backoffice/dossiers/show.html.haml
+++ b/app/views/backoffice/dossiers/show.html.haml
@@ -16,7 +16,7 @@
=render partial: '/dossiers/pieces_justificatives'
%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..2ffdf472d
--- /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: :update } 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 166913fbc..74930f900 100644
--- a/app/views/dossiers/show.html.haml
+++ b/app/views/dossiers/show.html.haml
@@ -1,13 +1 @@
-.container
- %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/layouts/application.html.haml b/app/views/layouts/application.html.haml
index 445c8b63a..f9048fa5a 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -17,6 +17,11 @@
%div{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
= current_gestionnaire.email
= link_to "Déconnexion", '/gestionnaires/sign_out', method: :delete, :class => 'btn btn-md'
+ - elsif user_signed_in?
+ %div.user{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
+ %i.fa.fa-user
+ = current_user.email
+ = link_to "Déconnexion", '/users/sign_out', method: :delete, :class => 'btn btn-md'
#flash_message.center
- if flash.notice
diff --git a/app/views/start/_admin.html.haml b/app/views/start/_admin.html.haml
deleted file mode 100644
index 10a86bcc6..000000000
--- a/app/views/start/_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/users/confirmations/new.html.erb b/app/views/users/confirmations/new.html.erb
new file mode 100644
index 000000000..3df9635f9
--- /dev/null
+++ b/app/views/users/confirmations/new.html.erb
@@ -0,0 +1,16 @@
+
Resend confirmation instructions
+
+<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %>
+
+
+
+ <%= f.submit "Resend confirmation instructions" %>
+
+<% end %>
+
+<%= render "users/shared/links" %>
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/index.html.haml b/app/views/users/dossiers/index.html.haml
new file mode 100644
index 000000000..30f4a7fb4
--- /dev/null
+++ b/app/views/users/dossiers/index.html.haml
@@ -0,0 +1,10 @@
+%h1 Vos dossiers :
+
+%table.table
+ %thead
+ %th Nom du Projet
+ %th Mise à jour
+ - @dossiers.each do |dossier|
+ %tr
+ %td= dossier.nom_projet
+ %td= dossier.last_update
\ No newline at end of file
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/users/mailer/confirmation_instructions.html.erb b/app/views/users/mailer/confirmation_instructions.html.erb
new file mode 100644
index 000000000..dc55f64f6
--- /dev/null
+++ b/app/views/users/mailer/confirmation_instructions.html.erb
@@ -0,0 +1,5 @@
+Welcome <%= @email %>!
+
+You can confirm your account email through the link below:
+
+<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>
diff --git a/app/views/users/mailer/reset_password_instructions.html.erb b/app/views/users/mailer/reset_password_instructions.html.erb
new file mode 100644
index 000000000..f667dc12f
--- /dev/null
+++ b/app/views/users/mailer/reset_password_instructions.html.erb
@@ -0,0 +1,8 @@
+Hello <%= @resource.email %>!
+
+Someone has requested a link to change your password. You can do this through the link below.
+
+<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>
+
+If you didn't request this, please ignore this email.
+Your password won't change until you access the link above and create a new one.
diff --git a/app/views/users/mailer/unlock_instructions.html.erb b/app/views/users/mailer/unlock_instructions.html.erb
new file mode 100644
index 000000000..41e148bf2
--- /dev/null
+++ b/app/views/users/mailer/unlock_instructions.html.erb
@@ -0,0 +1,7 @@
+Hello <%= @resource.email %>!
+
+Your account has been locked due to an excessive number of unsuccessful sign in attempts.
+
+Click the link below to unlock your account:
+
+<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>
diff --git a/app/views/users/passwords/edit.html.erb b/app/views/users/passwords/edit.html.erb
new file mode 100644
index 000000000..94404bdb2
--- /dev/null
+++ b/app/views/users/passwords/edit.html.erb
@@ -0,0 +1,22 @@
+Change your password
+
+<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
+ <%= devise_error_messages! %>
+ <%= f.hidden_field :reset_password_token %>
+
+
+ <%= f.label :password, "New password" %>
+ <%= f.password_field :password, autofocus: true, autocomplete: "off" %>
+
+
+
+ <%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
+
+
+
+ <%= f.submit "Change my password" %>
+
+<% end %>
+
+<%= render "users/shared/links" %>
diff --git a/app/views/users/passwords/new.html.erb b/app/views/users/passwords/new.html.erb
new file mode 100644
index 000000000..808f4cbc8
--- /dev/null
+++ b/app/views/users/passwords/new.html.erb
@@ -0,0 +1,16 @@
+Forgot your password?
+
+<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %>
+
+
+
+ <%= f.submit "Send me reset password instructions" %>
+
+<% end %>
+
+<%= render "users/shared/links" %>
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/users/recapitulatif/show.html.haml b/app/views/users/recapitulatif/show.html.haml
new file mode 100644
index 000000000..f5e5f09e2
--- /dev/null
+++ b/app/views/users/recapitulatif/show.html.haml
@@ -0,0 +1,25 @@
+%div.row#recap_dossier
+ %div.col-md-2.col-lg-2
+ %h2
+ ='Récapitulatif'
+
+ %div.col-md-8.col-lg-8
+
+ %div.col-md-2.col-lg-2
+ %h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'}
+ = "Dossier n°#{@dossier.id}"
+ -#%h3{:class => 'text-success', :style => 'text-align:right'}
+ -# = @dossier.state_fr
+ - unless gestionnaire_signed_in?
+ %button#action_button.btn.btn-success
+ = 'Soumettre mon dossier'
+
+%div{style: 'text-align:center'}
+ -if (request.referer != nil) && (request.referer.include?'/description') && !(request.referer.include?'back_url=recapitulatif')
+ %h3.text-success Félicitation, votre demande a bien été enregistrée.
+
+%br
+
+= render partial: '/dossiers/infos_dossier'
+%br
+= render partial: 'commentaires_flux'
\ No newline at end of file
diff --git a/app/views/users/recapitulatif/show.html_BACKUP_4662.haml b/app/views/users/recapitulatif/show.html_BACKUP_4662.haml
new file mode 100644
index 000000000..8e2f661b2
--- /dev/null
+++ b/app/views/users/recapitulatif/show.html_BACKUP_4662.haml
@@ -0,0 +1,29 @@
+<<<<<<< HEAD:app/views/recapitulatif/show.html.haml
+%div.row
+ %div.col-md-2.col-lg-2
+ %h2
+ ='Récapitulatif'
+=======
+%h2#recap_dossier Récapitulatif
+>>>>>>> 6eeac88c95dce079195f596e05a7e652fd9720c9:app/views/users/recapitulatif/show.html.haml
+
+ %div.col-md-8.col-lg-8
+
+ %div.col-md-2.col-lg-2
+ %h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'}
+ = "Dossier n°#{@dossier.id}"
+ -#%h3{:class => 'text-success', :style => 'text-align:right'}
+ -# = @dossier.state_fr
+ - unless gestionnaire_signed_in?
+ %button#action_button.btn.btn-success
+ = 'Soumettre mon dossier'
+
+%div{style: 'text-align:center'}
+ -if (request.referer != nil) && (request.referer.include?'/description') && !(request.referer.include?'back_url=recapitulatif')
+ %h3.text-success Félicitation, votre demande a bien été enregistrée.
+
+%br
+
+= render partial: '/dossiers/infos_dossier'
+%br
+= render partial: 'commentaires_flux'
\ No newline at end of file
diff --git a/app/views/users/recapitulatif/show.html_BASE_4662.haml b/app/views/users/recapitulatif/show.html_BASE_4662.haml
new file mode 100644
index 000000000..571490579
--- /dev/null
+++ b/app/views/users/recapitulatif/show.html_BASE_4662.haml
@@ -0,0 +1,24 @@
+%h2
+ ='Récapitulatif'
+
+%div{style: 'text-align:center'}
+ -if request.referer != nil
+ -if (request.referer.include?'/description') && !(request.referer.include?'back_url=recapitulatif')
+ %h4.text-success Félicitation, votre demande a bien été enregistrée.
+
+ %h3{style: 'text-align:center; line-height:1.5em'}
+ ='Votre dossier est le '
+ %br
+ %span{id: 'dossier_id', style: 'font-weight:bold;', class: 'text-success'}
+ ="n°#{@dossier.id}"
+ -else
+ %h2#dossier_id{:class => 'text-info', :style => 'text-align:right'}
+ = "Dossier n°#{@dossier.id}"
+ -else
+ %h2#dossier_id{:class => 'text-info', :style => 'text-align:right'}
+ = "Dossier n°#{@dossier.id}"
+
+= render partial: '/dossiers/infos_dossier'
+%br
+
+= render partial: 'commentaires_flux'
\ No newline at end of file
diff --git a/app/views/recapitulatif/show.html.haml b/app/views/users/recapitulatif/show.html_LOCAL_4662.haml
similarity index 100%
rename from app/views/recapitulatif/show.html.haml
rename to app/views/users/recapitulatif/show.html_LOCAL_4662.haml
diff --git a/app/views/users/recapitulatif/show.html_REMOTE_4662.haml b/app/views/users/recapitulatif/show.html_REMOTE_4662.haml
new file mode 100644
index 000000000..96d1e714f
--- /dev/null
+++ b/app/views/users/recapitulatif/show.html_REMOTE_4662.haml
@@ -0,0 +1,23 @@
+%h2#recap_dossier Récapitulatif
+
+%div{style: 'text-align:center'}
+ -if request.referer != nil
+ -if (request.referer.include?'/description') && !(request.referer.include?'back_url=recapitulatif')
+ %h4.text-success Félicitation, votre demande a bien été enregistrée.
+
+ %h3{style: 'text-align:center; line-height:1.5em'}
+ ='Votre dossier est le '
+ %br
+ %span{id: 'dossier_id', style: 'font-weight:bold;', class: 'text-success'}
+ ="n°#{@dossier.id}"
+ -else
+ %h2#dossier_id{:class => 'text-info', :style => 'text-align:right'}
+ = "Dossier n°#{@dossier.id}"
+ -else
+ %h2#dossier_id{:class => 'text-info', :style => 'text-align:right'}
+ = "Dossier n°#{@dossier.id}"
+
+= render partial: '/dossiers/infos_dossier'
+%br
+
+= render partial: 'commentaires_flux'
\ No newline at end of file
diff --git a/app/views/users/registrations/edit.html.erb b/app/views/users/registrations/edit.html.erb
new file mode 100644
index 000000000..3ea40f014
--- /dev/null
+++ b/app/views/users/registrations/edit.html.erb
@@ -0,0 +1,39 @@
+Edit <%= resource_name.to_s.humanize %>
+
+<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
+ <%= devise_error_messages! %>
+
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %>
+
+
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
+ Currently waiting confirmation for: <%= resource.unconfirmed_email %>
+ <% end %>
+
+
+ <%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, autocomplete: "off" %>
+
+
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
+
+
+
+ <%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password, autocomplete: "off" %>
+
+
+
+ <%= f.submit "Update" %>
+
+<% end %>
+
+Cancel my account
+
+Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
+
+<%= link_to "Back", :back %>
diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb
new file mode 100644
index 000000000..f9bbd8abd
--- /dev/null
+++ b/app/views/users/registrations/new.html.erb
@@ -0,0 +1,29 @@
+Sign up
+
+<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
+ <%= devise_error_messages! %>
+
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %>
+
+
+
+ <%= f.label :password %>
+ <% if @validatable %>
+ (<%= @minimum_password_length %> characters minimum)
+ <% end %>
+ <%= f.password_field :password, autocomplete: "off" %>
+
+
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
+
+
+
+ <%= f.submit "Sign up" %>
+
+<% end %>
+
+<%= render "users/shared/links" %>
diff --git a/app/views/users/sessions/new.html.haml b/app/views/users/sessions/new.html.haml
new file mode 100644
index 000000000..9abc9ef8f
--- /dev/null
+++ b/app/views/users/sessions/new.html.haml
@@ -0,0 +1,19 @@
+%h2#login_user Connexion
+= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
+ .field
+ = f.label :email
+ %br
+ = f.email_field :email, autofocus: true
+ .field
+ = f.label :password
+ %br
+ = f.password_field :password, autocomplete: "off"
+ %br
+ / - if devise_mapping.rememberable?
+ / .field
+ / = f.check_box :remember_me
+ / = f.label :remember_me
+ .actions
+ = f.submit "Se connecter"
+
+= render "users/shared/links"
diff --git a/app/views/users/shared/_links.html.erb b/app/views/users/shared/_links.html.erb
new file mode 100644
index 000000000..cd795adb6
--- /dev/null
+++ b/app/views/users/shared/_links.html.erb
@@ -0,0 +1,25 @@
+<%- if controller_name != 'sessions' %>
+ <%= link_to "Log in", new_session_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
+ <%= link_to "Sign up", new_registration_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.omniauthable? %>
+ <%- resource_class.omniauth_providers.each do |provider| %>
+ <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
+ <% end -%>
+<% end -%>
diff --git a/app/views/start/_pro.html.haml b/app/views/users/siret/_pro.html.haml
similarity index 100%
rename from app/views/start/_pro.html.haml
rename to app/views/users/siret/_pro.html.haml
diff --git a/app/views/start/index.html.haml b/app/views/users/siret/index.html.haml
similarity index 92%
rename from app/views/start/index.html.haml
rename to app/views/users/siret/index.html.haml
index fe9aa62d7..04e760ffc 100644
--- a/app/views/start/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: '/start/pro'
+ = render partial: 'pro'
diff --git a/app/views/users/unlocks/new.html.erb b/app/views/users/unlocks/new.html.erb
new file mode 100644
index 000000000..1eefabbb8
--- /dev/null
+++ b/app/views/users/unlocks/new.html.erb
@@ -0,0 +1,16 @@
+Resend unlock instructions
+
+<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %>
+
+
+
+ <%= f.submit "Resend unlock instructions" %>
+
+<% end %>
+
+<%= render "users/shared/links" %>
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 6591b7048..dff830200 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -78,5 +78,7 @@ fr:
not_saved:
one: "1 erreur a empêché ce(tte) %{resource} d'être sauvegardé(e) :"
other: "%{count} erreurs ont empêché ce(tte) %{resource} d'être sauvegardé(e) :"
+ dossier_not_found: "Le dossier n'existe pas"
+ invalid_siret: "Le siret est incorrect"
diff --git a/config/routes.rb b/config/routes.rb
index f4fb5ace6..b444f1241 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,35 +1,50 @@
Rails.application.routes.draw do
+
+ devise_for :users, controllers: {
+ sessions: 'users/sessions'
+ }
+
devise_for :gestionnaires, controllers: {
sessions: 'gestionnaires/sessions'
-
}, skip: [:password, :registrations]
- root 'start#index'
+ # root 'welcome#index'
+ root 'users/dossiers#index'
- get 'start/index'
- get 'start/error_siret'
- get 'start/error_login'
- get 'start/error_dossier'
+ 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/db/migrate/20150922141232_create_users.rb b/db/migrate/20150922141232_create_users.rb
new file mode 100644
index 000000000..372296c3c
--- /dev/null
+++ b/db/migrate/20150922141232_create_users.rb
@@ -0,0 +1,42 @@
+class CreateUsers < ActiveRecord::Migration
+ def change
+ create_table(:users) do |t|
+ ## Database authenticatable
+ t.string :email, null: false, default: ""
+ t.string :encrypted_password, null: false, default: ""
+
+ ## Recoverable
+ t.string :reset_password_token
+ t.datetime :reset_password_sent_at
+
+ ## Rememberable
+ t.datetime :remember_created_at
+
+ ## Trackable
+ t.integer :sign_in_count, default: 0, null: false
+ t.datetime :current_sign_in_at
+ t.datetime :last_sign_in_at
+ t.inet :current_sign_in_ip
+ t.inet :last_sign_in_ip
+
+ ## Confirmable
+ # t.string :confirmation_token
+ # t.datetime :confirmed_at
+ # t.datetime :confirmation_sent_at
+ # t.string :unconfirmed_email # Only if using reconfirmable
+
+ ## Lockable
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
+ # t.datetime :locked_at
+
+
+ t.timestamps
+ end
+
+ add_index :users, :email, unique: true
+ add_index :users, :reset_password_token, unique: true
+ # add_index :users, :confirmation_token, unique: true
+ # add_index :users, :unlock_token, unique: true
+ end
+end
diff --git a/db/migrate/20150923101000_add_user_to_dossier.rb b/db/migrate/20150923101000_add_user_to_dossier.rb
new file mode 100644
index 000000000..0bf8685b4
--- /dev/null
+++ b/db/migrate/20150923101000_add_user_to_dossier.rb
@@ -0,0 +1,6 @@
+class AddUserToDossier < ActiveRecord::Migration
+ def change
+ add_reference :dossiers, :user, index: true
+ add_foreign_key :dossiers, :users
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index bf38d0ec4..7930f66c9 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150922141000) do
+ActiveRecord::Schema.define(version: 20150923101000) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -46,10 +46,12 @@ ActiveRecord::Schema.define(version: 20150922141000) do
t.date "date_previsionnelle"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "state"
+ t.string "state"
+ t.integer "user_id"
end
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
+ add_index "dossiers", ["user_id"], name: "index_dossiers_on_user_id", using: :btree
create_table "entreprises", force: :cascade do |t|
t.string "siren"
@@ -130,6 +132,25 @@ ActiveRecord::Schema.define(version: 20150922141000) do
t.integer "procedure_id"
end
+ create_table "users", force: :cascade do |t|
+ t.string "email", default: "", null: false
+ t.string "encrypted_password", default: "", null: false
+ t.string "reset_password_token"
+ t.datetime "reset_password_sent_at"
+ t.datetime "remember_created_at"
+ t.integer "sign_in_count", default: 0, null: false
+ t.datetime "current_sign_in_at"
+ t.datetime "last_sign_in_at"
+ t.inet "current_sign_in_ip"
+ t.inet "last_sign_in_ip"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
+ add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
+
add_foreign_key "cerfas", "dossiers"
add_foreign_key "commentaires", "dossiers"
+ add_foreign_key "dossiers", "users"
end
diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb
index 7023432df..da789d0e4 100644
--- a/spec/controllers/backoffice/dossiers_controller_spec.rb
+++ b/spec/controllers/backoffice/dossiers_controller_spec.rb
@@ -19,7 +19,7 @@ describe Backoffice::DossiersController, type: :controller do
it "le numéro de dossier n'existe pas" do
get :show, id: bad_dossier_id
- expect(response).to redirect_to('/start/error_dossier')
+ expect(response).to redirect_to('/backoffice')
end
end
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 894378bd9..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 }
@@ -13,7 +13,7 @@ describe DescriptionController, type: :controller do
it 'redirection vers start si mauvais dossier ID' do
get :show, dossier_id: bad_dossier_id
- expect(response).to redirect_to(controller: :start, action: :error_dossier)
+ expect(response).to redirect_to(controller: :siret)
end
end
@@ -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 65136dbbd..041b25c4f 100644
--- a/spec/controllers/dossiers_controller_spec.rb
+++ b/spec/controllers/dossiers_controller_spec.rb
@@ -1,119 +1,124 @@
require 'spec_helper'
-RSpec.describe DossiersController, type: :controller do
- let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
- let(:dossier_id) { dossier.id }
- let(:siret_not_found) { 999_999_999_999 }
+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(: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 start si mauvais dossier ID' do
- get :show, id: siret_not_found
- expect(response).to redirect_to('/start/error_dossier')
- 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
- before do
- post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last
- end
+ # describe 'professionnel fills form' do
+ # context 'when pro_dossier_id is empty' do
+ # context 'with valid siret ' do
- it 'create a dossier' do
- expect { post :create, siret: siret, pro_dossier_id: '' }.to change { Dossier.count }.by(1)
- end
+ # subject { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }
- it 'creates entreprise' do
- expect { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }.to change { Entreprise.count }.by(1)
- end
- it 'links entreprise to dossier' do
- expect(Entreprise.last.dossier).to eq(Dossier.last)
- end
+ # it 'create a dossier' do
+ # expect { subject }.to change { Dossier.count }.by(1)
+ # end
- it 'creates etablissement for dossier' do
- expect { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }.to change { Etablissement.count }.by(1)
- end
+ # it 'creates entreprise' do
+ # expect { subject }.to change { Entreprise.count }.by(1)
+ # end
- it 'links etablissement to dossier' do
- expect(Etablissement.last.dossier).to eq(Dossier.last)
- end
+ # it 'links entreprise to dossier' do
+ # expect(Entreprise.last.dossier).to eq(Dossier.last)
+ # end
- it 'links etablissement to entreprise' do
- expect(Etablissement.last.entreprise).to eq(Entreprise.last)
- end
+ # it 'creates etablissement for dossier' do
+ # expect { subject }.to change { Etablissement.count }.by(1)
+ # end
- it 'links procedure to dossier' do
- expect(Dossier.last.procedure).to eq(Procedure.last)
- end
+ # it 'links etablissement to dossier' do
+ # subject
+ # expect(Etablissement.last.dossier).to eq(Dossier.last)
+ # end
- it 'state of dossier is draft' do
- expect(Dossier.last.state).to eq('draft')
- end
- end
+ # it 'links etablissement to entreprise' do
+ # subject
+ # expect(Etablissement.last.entreprise).to eq(Entreprise.last)
+ # end
- context 'with non existant siret' do
- let(:siret_not_found) { '11111111111111' }
- subject { post :create, siret: siret_not_found, pro_dossier_id: '' }
- it 'does not create new dossier' do
- expect { subject }.not_to change { Dossier.count }
- end
+ # it 'links procedure to dossier' do
+ # subject
+ # expect(Dossier.last.procedure).to eq(Procedure.last)
+ # end
- it 'redirects to show' do
- expect(subject).to redirect_to(controller: :start, action: :error_siret)
- end
- end
- end
- end
- end
+ # it 'state of dossier is draft' do
+ # subject
+ # expect(Dossier.last.state).to eq('draft')
+ # 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
+ # 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 'update dossier' do
- dossier.reload
- expect(dossier.autorisation_donnees).to be_truthy
- end
- end
+ # it 'redirects to show' do
+ # expect(subject).to redirect_to(controller: :siret, procedure_id: procedure.id)
+ # end
+ # end
+ # end
+ # 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
+ # 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 "doesn't update dossier autorisation_donnees" do
- dossier.reload
- expect(dossier.autorisation_donnees).to be_falsy
- end
- 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
+
+ # 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/recapitulatif_controller_spec.rb b/spec/controllers/recapitulatif_controller_spec.rb
deleted file mode 100644
index 609ddbf22..000000000
--- a/spec/controllers/recapitulatif_controller_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'spec_helper'
-
-RSpec.describe RecapitulatifController, type: :controller do
- let(:dossier) { create(:dossier) }
-
- let(:bad_dossier_id) { Dossier.count + 10 }
-
- describe 'GET #show' do
- it 'returns http success' do
- get :show, dossier_id: dossier.id
- expect(response).to have_http_status(:success)
- end
-
- it 'redirection vers start si mauvais dossier ID' do
- get :show, dossier_id: bad_dossier_id
- expect(response).to redirect_to('/start/error_dossier')
- end
- end
-end
diff --git a/spec/controllers/start_controller_spec.rb b/spec/controllers/start_controller_spec.rb
deleted file mode 100644
index b8d1c3e5d..000000000
--- a/spec/controllers/start_controller_spec.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require 'spec_helper'
-
-RSpec.describe StartController, type: :controller do
- let!(:procedure) { create(:procedure) }
-
- describe 'GET #index' do
- before do
- get :index, procedure_id: procedure
- end
-
- context 'when params procedure_id is present' do
- context 'when procedure_id is valid' do
- it { expect(response).to have_http_status(:success) }
- end
-
- context 'when procedure_id is not valid' do
- let(:procedure) { '' }
- it { expect(response).to have_http_status(404) }
- end
- end
-
- context 'when params procedure_id is not present' do
- before do
- get :index
- end
- it { expect(response).to have_http_status(404) }
- end
- end
-
- describe 'GET #index with bad SIRET' do
- before do
- get :error_siret, procedure_id: procedure
- end
-
- it 'returns http success and flash alert is present' do
- expect(response).to have_http_status(:success)
- end
- it 'la flash alert est présente' do
- expect(flash[:alert]).to be_present
- end
- it 'la flash alert a un libellé correct' do
- expect(flash[:alert]).to have_content('Ce SIRET n\'est pas valide')
- end
- end
-
- describe 'GET #index with bad LOGIN' do
- before do
- get :error_login
- end
-
- it 'returns http success and flash alert is present' do
- expect(response).to have_http_status(:success)
- end
- it 'la flash alert est présente' do
- expect(flash[:alert]).to be_present
- end
- it 'la flash alert a un libellé correct' do
- expect(flash[:alert]).to have_content('Ce compte n\'existe pas')
- end
- end
-
- describe 'GET #index with bad DOSSIER' do
- before do
- get :error_dossier
- end
-
- it 'returns http success and flash alert is present' do
- expect(response).to have_http_status(:success)
- end
- it 'la flash alert est présente' do
- expect(flash[:alert]).to be_present
- end
- it 'la flash alert a un libellé correct' do
- expect(flash[:alert]).to have_content('Ce dossier n\'existe pas')
- end
- end
-end
diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb
new file mode 100644
index 000000000..ac6083304
--- /dev/null
+++ b/spec/controllers/users/dossiers_controller_spec.rb
@@ -0,0 +1,148 @@
+require 'spec_helper'
+
+describe Users::DossiersController, type: :controller do
+ describe '.index' do
+ subject { get :index }
+ context 'when user is not logged in' do
+ it { is_expected.to redirect_to('/users/sign_in') }
+ end
+ context 'when user is logged in' do
+ before do
+ sign_in create(:user)
+ end
+ it { is_expected.to render_template('users/dossiers/index') }
+ 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/users/recapitulatif_controller_spec.rb b/spec/controllers/users/recapitulatif_controller_spec.rb
new file mode 100644
index 000000000..e40e48804
--- /dev/null
+++ b/spec/controllers/users/recapitulatif_controller_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe Users::RecapitulatifController, type: :controller do
+ let(:dossier) { create(:dossier, :with_user) }
+
+ 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)
+ end
+
+ it 'redirection vers siret si mauvais dossier ID' do
+ get :show, dossier_id: bad_dossier_id
+ expect(response).to redirect_to('/users/siret')
+ end
+ end
+end
diff --git a/spec/controllers/users/siret_controller_spec.rb b/spec/controllers/users/siret_controller_spec.rb
new file mode 100644
index 000000000..cf6b48151
--- /dev/null
+++ b/spec/controllers/users/siret_controller_spec.rb
@@ -0,0 +1,82 @@
+require 'spec_helper'
+
+describe Users::SiretController, type: :controller do
+ let!(:procedure) { create(:procedure) }
+
+ describe 'GET #index' do
+ before do
+ get :index, procedure_id: procedure
+ end
+
+ context 'when params procedure_id is present' do
+ context 'when procedure_id is valid' do
+ context 'when user is logged in' do
+ before do
+ sign_in create(:user)
+ end
+ subject { get :index, procedure_id: procedure }
+ it { expect(subject).to have_http_status(:success) }
+ context 'when procedure_id is not valid' do
+ let(:procedure) { '' }
+ it { is_expected.to have_http_status(404) }
+ end
+ context 'when params procedure_id is not present' do
+ subject { get :index }
+ it { is_expected.to have_http_status(404) }
+ end
+ end
+ context 'when user is not logged' do
+ it { expect(response).to have_http_status(302) }
+ end
+ end
+ end
+ end
+
+ # describe 'GET #index with bad SIRET' do
+ # before do
+ # get :error_siret, procedure_id: procedure
+ # end
+
+ # it 'returns http success and flash alert is present' do
+ # expect(response).to have_http_status(:success)
+ # end
+ # it 'la flash alert est présente' do
+ # expect(flash[:alert]).to be_present
+ # end
+ # it 'la flash alert a un libellé correct' do
+ # expect(flash[:alert]).to have_content('Ce SIRET n\'est pas valide')
+ # end
+ # end
+
+ # describe 'GET #index with bad LOGIN' do
+ # before do
+ # get :error_login
+ # end
+
+ # it 'returns http success and flash alert is present' do
+ # expect(response).to have_http_status(:success)
+ # end
+ # it 'la flash alert est présente' do
+ # expect(flash[:alert]).to be_present
+ # end
+ # it 'la flash alert a un libellé correct' do
+ # expect(flash[:alert]).to have_content('Ce compte n\'existe pas')
+ # end
+ # end
+
+ # describe 'GET #index with bad DOSSIER' do
+ # before do
+ # get :error_dossier
+ # end
+
+ # it 'returns http success and flash alert is present' do
+ # expect(response).to have_http_status(:success)
+ # end
+ # it 'la flash alert est présente' do
+ # expect(flash[:alert]).to be_present
+ # end
+ # it 'la flash alert a un libellé correct' do
+ # expect(flash[:alert]).to have_content('Ce dossier n\'existe pas')
+ # end
+ # end
+end
diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb
index 00ea31b39..589719c3d 100644
--- a/spec/factories/dossier.rb
+++ b/spec/factories/dossier.rb
@@ -17,5 +17,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/factories/user.rb b/spec/factories/user.rb
new file mode 100644
index 000000000..4612d1e12
--- /dev/null
+++ b/spec/factories/user.rb
@@ -0,0 +1,7 @@
+FactoryGirl.define do
+ sequence(:user_email) { |n| "plop#{n}@plop.com" }
+ factory :user do
+ email { generate(:user_email) }
+ password 'password'
+ end
+end
\ No newline at end of file
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
new file mode 100644
index 000000000..4da764172
--- /dev/null
+++ b/spec/features/recapitulatif_page/_commentaires_flux_spec.rb
@@ -0,0 +1,38 @@
+require 'spec_helper'
+
+feature '_Commentaires_Flux Recapitulatif#Show Page' do
+ let(:dossier) { create(:dossier, :with_user, :with_procedure) }
+ 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
+ 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_css('#email_contact')
+ end
+
+ scenario 'la date du commentaire est présent' do
+ expect(page).to have_selector('span[id=created_at]')
+ end
+
+ scenario 'le corps du commentaire est présent' do
+ 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='/users/dossiers/#{dossier_id}/commentaire'][method=post]")
+ end
+
+ scenario 'Champs de texte' do
+ expect(page).to have_selector('textarea[id=texte_commentaire][name=texte_commentaire]')
+ end
+ end
+end
diff --git a/spec/features/recapitulatif_page/show_page_spec.rb b/spec/features/recapitulatif_page/show_page_spec.rb
index ef380cdbd..da9a6ffea 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, :with_procedure) }
+ let(:dossier) { create(:dossier, :with_user, :with_procedure) }
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/complete_demande_spec.rb b/spec/features/users/complete_demande_spec.rb
new file mode 100644
index 000000000..7931177b0
--- /dev/null
+++ b/spec/features/users/complete_demande_spec.rb
@@ -0,0 +1,63 @@
+require 'spec_helper'
+
+feature 'user path for dossier creation' do
+ let(:user) { create(:user) }
+ let(:procedure) { create(:procedure) }
+ let(:siret) { '53272417600013' }
+ let(:siren) { siret[0...9] }
+ context 'user arrives on siret page' do
+ before do
+ visit users_siret_path(procedure_id: procedure.id)
+ end
+
+ scenario 'he is redirected on login page' do
+ expect(page).to have_css('#login_user')
+ end
+
+ context 'user sign_in' do
+ before do
+ page.find_by_id('user_email').set user.email
+ page.find_by_id('user_password').set user.password
+ page.click_on 'Se connecter'
+ end
+ scenario 'redirects to siret page' do
+ expect(page).to have_css('#siret')
+ end
+ context 'sets siret' do
+ before do
+ stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
+ .to_return(body: File.read('spec/support/files/etablissement.json', status: 200))
+ 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'))
+ page.find_by_id('siret').set siret
+ page.click_on 'Commencer'
+ end
+ scenario 'user is on page recap info entreprise' do
+ expect(page).to have_css('#recap_info_entreprise')
+ end
+ context 'when validating info entreprise recap page' do
+ before do
+ page.check('dossier_autorisation_donnees')
+ page.click_on 'Etape suivante'
+ end
+ scenario 'user is on description page' do
+ expect(page).to have_css('#description_page')
+ end
+ context 'user fill and validate description page' do
+ before do
+ page.find_by_id('nom_projet').set 'Mon super projet'
+ page.find_by_id('description').set 'Ma super description'
+ page.find_by_id('montant_projet').set 10_000
+ page.find_by_id('montant_aide_demande').set 1_000
+ page.find_by_id('date_previsionnelle').set '09/09/2015'
+ page.click_on 'Terminer la procédure'
+ end
+ scenario 'user is on recap page' do
+ expect(page).to have_css('#recap_dossier')
+ end
+ end
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/features/users/list_dossiers_spec.rb b/spec/features/users/list_dossiers_spec.rb
new file mode 100644
index 000000000..2d1db6656
--- /dev/null
+++ b/spec/features/users/list_dossiers_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+feature 'user access to the list of his dossier' do
+
+ let(:user) { create(:user) }
+ let!(:dossier1) { create(:dossier) }
+ before do
+ visit root_path
+ page.find_by_id('user_email').set user.email
+ page.find_by_id('user_password').set user.password
+ page.click_on 'Se connecter'
+ end
+ scenario 'the list of dossier is displayed' do
+ expect(page).to have_content(dossier1.nom_projet)
+ end
+end
\ No newline at end of file
diff --git a/spec/features/users/start_demande_spec.rb b/spec/features/users/start_demande_spec.rb
new file mode 100644
index 000000000..b1ac18d06
--- /dev/null
+++ b/spec/features/users/start_demande_spec.rb
@@ -0,0 +1,39 @@
+require 'spec_helper'
+
+feature 'user arrive on siret page' do
+ let(:procedure) { create(:procedure) }
+ let(:user) { create(:user) }
+ let(:siret) { '42149333900020' }
+ let(:siren) { siret[0...9] }
+ context 'when user is not logged in' do
+ before do
+ visit users_siret_path(procedure_id: procedure.id)
+ end
+ scenario 'he is redirected to login page' do
+ expect(page).to have_css('#login_user')
+ end
+ context 'when he enter login information' do
+ before do
+ page.find_by_id('user_email').set user.email
+ page.find_by_id('user_password').set user.password
+ page.click_on 'Se connecter'
+ end
+ scenario 'he is redirected to siret page to enter a siret' do
+ expect(page).to have_css('#pro_section')
+ end
+ context 'when enter a siret' do
+ before do
+ 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'))
+ page.find_by_id('siret').set siret
+ page.click_on 'Commencer'
+ end
+ scenario 'he is redirected to recap info entreprise page' do
+ expect(page).to have_css('#recap_info_entreprise')
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb
index eda807c07..3f785b819 100644
--- a/spec/models/dossier_spec.rb
+++ b/spec/models/dossier_spec.rb
@@ -21,6 +21,7 @@ describe Dossier do
it { is_expected.to have_one(:cerfa) }
it { is_expected.to have_one(:etablissement) }
it { is_expected.to have_one(:entreprise) }
+ it { is_expected.to belong_to(:user) }
end
describe 'delegation' do
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
new file mode 100644
index 000000000..ca38b1986
--- /dev/null
+++ b/spec/models/user_spec.rb
@@ -0,0 +1,21 @@
+require 'rails_helper'
+
+describe User, type: :model do
+ describe 'database columns' do
+ it { is_expected.to have_db_column(:email) }
+ it { is_expected.to have_db_column(:encrypted_password) }
+ it { is_expected.to have_db_column(:reset_password_token) }
+ it { is_expected.to have_db_column(:reset_password_sent_at) }
+ it { is_expected.to have_db_column(:remember_created_at) }
+ it { is_expected.to have_db_column(:sign_in_count) }
+ it { is_expected.to have_db_column(:current_sign_in_at) }
+ it { is_expected.to have_db_column(:last_sign_in_at) }
+ it { is_expected.to have_db_column(:current_sign_in_ip) }
+ it { is_expected.to have_db_column(:last_sign_in_ip) }
+ it { is_expected.to have_db_column(:created_at) }
+ it { is_expected.to have_db_column(:updated_at) }
+ end
+ describe 'associations' do
+ it { is_expected.to have_many(:dossiers) }
+ end
+end
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/users/dossiers/index.html.haml_spec.rb b/spec/views/users/dossiers/index.html.haml_spec.rb
new file mode 100644
index 000000000..bd88b8ddc
--- /dev/null
+++ b/spec/views/users/dossiers/index.html.haml_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe 'users/dossiers/index.html.haml', type: :view do
+
+ describe 'list dossiers' do
+ let(:dossier1) { create(:dossier).decorate }
+ let(:dossier2) { create(:dossier).decorate }
+ before do
+ assign(:dossiers, [dossier1, dossier2])
+ render
+ end
+ subject { rendered }
+ it { expect(subject).to have_content(dossier1.nom_projet) }
+ end
+
+end
\ No newline at end of file
diff --git a/spec/views/recapitulatif/_commentaires_flux_spec.rb b/spec/views/users/recapitulatif/_commentaires_flux_spec.rb
similarity index 82%
rename from spec/views/recapitulatif/_commentaires_flux_spec.rb
rename to spec/views/users/recapitulatif/_commentaires_flux_spec.rb
index fb320f4a8..a609c62ed 100644
--- a/spec/views/recapitulatif/_commentaires_flux_spec.rb
+++ b/spec/views/users/recapitulatif/_commentaires_flux_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
-describe 'recapitulatif/_commentaires_flux.html.haml', type: :view do
- let(:dossier) { create(:dossier) }
+describe 'users/recapitulatif/_commentaires_flux.html.haml', type: :view do
+ let(:dossier) { create(:dossier, :with_procedure) }
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') }
@@ -29,7 +29,7 @@ describe 'recapitulatif/_commentaires_flux.html.haml', type: :view do
context 'Affichage du formulaire de commentaire' do
it 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do
- expect(rendered).to have_selector("form[action='/dossiers/#{dossier_id}/commentaire'][method=post]")
+ expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/commentaire'][method=post]")
end
it 'Champs de texte' do
diff --git a/spec/views/recapitulatif/show.html.haml_spec.rb b/spec/views/users/recapitulatif/show.html.haml_spec.rb
similarity index 100%
rename from spec/views/recapitulatif/show.html.haml_spec.rb
rename to spec/views/users/recapitulatif/show.html.haml_spec.rb
diff --git a/spec/views/start/index.html.haml_spec.rb b/spec/views/users/siret/index.html.haml_spec.rb
similarity index 87%
rename from spec/views/start/index.html.haml_spec.rb
rename to spec/views/users/siret/index.html.haml_spec.rb
index b4334cbb7..5740ac7af 100644
--- a/spec/views/start/index.html.haml_spec.rb
+++ b/spec/views/users/siret/index.html.haml_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'start/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 'start/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