Merge branch 'develop' into staging

This commit is contained in:
Xavier J 2016-08-30 11:44:18 +02:00
commit 452d91e0a1
28 changed files with 250 additions and 78 deletions

View file

@ -82,7 +82,7 @@ gem 'mailjet'
gem "smart_listing" gem "smart_listing"
gem 'css_splitter' # gem 'css_splitter'
gem 'bootstrap-wysihtml5-rails', '~> 0.3.3.8' gem 'bootstrap-wysihtml5-rails', '~> 0.3.3.8'
gem 'as_csv' gem 'as_csv'

View file

@ -115,8 +115,6 @@ GEM
concurrent-ruby (1.0.2) concurrent-ruby (1.0.2)
crack (0.4.2) crack (0.4.2)
safe_yaml (~> 1.0.0) safe_yaml (~> 1.0.0)
css_splitter (0.4.5)
sprockets (>= 2.0.0)
database_cleaner (1.4.1) database_cleaner (1.4.1)
debug_inspector (0.0.2) debug_inspector (0.0.2)
deep_cloneable (2.2.1) deep_cloneable (2.2.1)
@ -636,7 +634,6 @@ DEPENDENCIES
chartkick chartkick
clamav-client clamav-client
coffee-rails (~> 4.1.0) coffee-rails (~> 4.1.0)
css_splitter
database_cleaner database_cleaner
deep_cloneable (~> 2.2.1) deep_cloneable (~> 2.2.1)
devise devise

View file

@ -187,7 +187,7 @@ class Admin::ProceduresController < AdminController
private private
def create_procedure_params def create_procedure_params
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :lien_site_web, :lien_notice, :euro_flag, :logo, :cerfa_flag, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id) params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :lien_site_web, :lien_notice, :euro_flag, :logo, :cerfa_flag, :for_individual, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id)
end end
def create_module_api_carto_params def create_module_api_carto_params

View file

@ -84,8 +84,12 @@ class Users::DossiersController < UsersController
@facade = facade params[:dossier][:id] @facade = facade params[:dossier][:id]
if checked_autorisation_donnees? if checked_autorisation_donnees?
@facade.dossier.update_attributes(update_params) begin
@facade.dossier.update_attributes!(update_params)
rescue
flash.now.alert = @facade.dossier.errors.full_messages.join('<br />').html_safe
return render 'show'
end
if @facade.dossier.procedure.module_api_carto.use_api_carto if @facade.dossier.procedure.module_api_carto.use_api_carto
redirect_to url_for(controller: :carte, action: :show, dossier_id: @facade.dossier.id) redirect_to url_for(controller: :carte, action: :show, dossier_id: @facade.dossier.id)
else else
@ -117,7 +121,7 @@ class Users::DossiersController < UsersController
end end
def update_params def update_params
params.require(:dossier).permit(:autorisation_donnees) params.require(:dossier).permit(:id, :autorisation_donnees, individual_attributes: [:nom, :prenom, :birthdate])
end end
def checked_autorisation_donnees? def checked_autorisation_donnees?

View file

@ -2,7 +2,7 @@ class EntrepriseDecorator < Draper::Decorator
delegate_all delegate_all
def raison_sociale_or_name def raison_sociale_or_name
raison_sociale.nil? ? nom + ' ' + prenom : raison_sociale raison_sociale.blank? ? nom + ' ' + prenom : raison_sociale
end end
def effectif def effectif

View file

@ -50,6 +50,10 @@ class DossierFacades
@dossier.ordered_champs_private @dossier.ordered_champs_private
end end
def individual
@dossier.individual
end
def commentaires_files def commentaires_files
PieceJustificative.where(dossier_id: @dossier.id, type_de_piece_justificative_id: nil) PieceJustificative.where(dossier_id: @dossier.id, type_de_piece_justificative_id: nil)
end end

View file

@ -14,6 +14,7 @@ class Dossier < ActiveRecord::Base
has_one :etablissement, dependent: :destroy has_one :etablissement, dependent: :destroy
has_one :entreprise, dependent: :destroy has_one :entreprise, dependent: :destroy
has_one :individual, dependent: :destroy
has_many :cerfa, dependent: :destroy has_many :cerfa, dependent: :destroy
has_many :pieces_justificatives, dependent: :destroy has_many :pieces_justificatives, dependent: :destroy
@ -28,6 +29,8 @@ class Dossier < ActiveRecord::Base
belongs_to :procedure belongs_to :procedure
belongs_to :user belongs_to :user
accepts_nested_attributes_for :individual
delegate :siren, to: :entreprise delegate :siren, to: :entreprise
delegate :siret, to: :etablissement, allow_nil: true delegate :siret, to: :etablissement, allow_nil: true
delegate :types_de_piece_justificative, to: :procedure delegate :types_de_piece_justificative, to: :procedure
@ -35,6 +38,7 @@ class Dossier < ActiveRecord::Base
delegate :france_connect_information, to: :user delegate :france_connect_information, to: :user
after_save :build_default_champs, if: Proc.new { procedure_id_changed? } after_save :build_default_champs, if: Proc.new { procedure_id_changed? }
after_save :build_default_individual, if: Proc.new { procedure.for_individual? }
validates :user, presence: true validates :user, presence: true
@ -66,6 +70,12 @@ class Dossier < ActiveRecord::Base
end end
end end
def build_default_individual
Individual.new(dossier_id: id).save(validate: false)
Entreprise.new(dossier_id: id).save(validate: false)
Etablissement.new(dossier_id: id, entreprise_id: entreprise.id).save(validate: false)
end
def ordered_champs def ordered_champs
champs.joins(', types_de_champ').where("champs.type_de_champ_id = types_de_champ.id AND types_de_champ.procedure_id = #{procedure.id}").order('order_place') champs.joins(', types_de_champ').where("champs.type_de_champ_id = types_de_champ.id AND types_de_champ.procedure_id = #{procedure.id}").order('order_place')
end end

View file

@ -4,4 +4,10 @@ class Entreprise < ActiveRecord::Base
has_one :rna_information, dependent: :destroy has_one :rna_information, dependent: :destroy
validates_presence_of :siren validates_presence_of :siren
before_save :default_values
def default_values
self.raison_sociale ||= ''
end
end end

9
app/models/individual.rb Normal file
View file

@ -0,0 +1,9 @@
class Individual < ActiveRecord::Base
belongs_to :dossier
validates_uniqueness_of :dossier_id
validates :nom, presence: true, allow_nil: false, allow_blank: false
validates :prenom, presence: true, allow_nil: false, allow_blank: false
validates :birthdate, presence: true, allow_nil: false, allow_blank: false
end

View file

@ -52,6 +52,17 @@
%h4 Formulaire / CERFA %h4 Formulaire / CERFA
%label %label
=f.check_box :cerfa_flag =f.check_box :cerfa_flag
Activer l'envoi de formulaire / CERFA Activer l'envoi de formulaire / CERFA
%br %br
=f.text_field :lien_demarche, class: 'form-control', placeholder: 'URL vers le formulaire vierge (facultatif)' =f.text_field :lien_demarche, class: 'form-control', placeholder: 'URL vers le formulaire vierge (facultatif)'
%br
.row
.col-md-6.col-lg-6
%h4 Particuliers
%label
=f.check_box :for_individual
Cette procédure s'adresse à un public qui
%b
ne possède pas de numéro SIRET,
qui doivent donc s'identifier en tant que personne physique.

View file

@ -7,8 +7,8 @@
= @facade.dossier.display_state = @facade.dossier.display_state
= render partial: 'follow_action' = render partial: 'follow_action'
- unless @facade.procedure.for_individual?
= render partial: '/dossiers/infos_entreprise' = render partial: '/dossiers/infos_entreprise'
= render partial: '/dossiers/infos_dossier' = render partial: '/dossiers/infos_dossier'
%br %br

View file

@ -1,40 +1,4 @@
.etape.etapes_menu.col-md-3.col-lg-3 - if @facade.procedure.for_individual?
%h3 = render partial: 'dossiers/etapes/etape_2/individual'
Mes informations - else
%br = render partial: 'dossiers/etapes/etape_2/entreprise'
- unless @facade.entreprise.nil?
.center{style:'margin-left: -5%'}
Vous êtes authentifié avec le SIRET
%h3.text-success
= @facade.etablissement.siret
= form_for @facade.dossier, url: users_dossier_change_siret_path(dossier_id: @facade.dossier.id), method: :put, remote: true do |f|
= f.submit 'Changer de SIRET', class: %w(btn btn-xs btn-primary)
.etape.etapes_informations.col-md-9.col-lg-9
.row
- if @facade.entreprise.nil?
#new_siret{style:'margin-left: 20%; margin-top: 5%'}
= form_for @facade.dossier, html: {class: 'form-inline'}, url: users_dossier_siret_informations_path(dossier_id: @facade.dossier.id), method: :post, remote: true do |f|
.form-group.form-group-lg
= f.text_field :siret, class: "form-control", placeholder: "Entrez votre Siret", value: @siret
= f.hidden_field :dossier_id, value: @facade.dossier.id
= f.submit 'Valider', class: %w(btn btn-lg btn-success), data: { disable_with: "Recherche en cours ..." }
- else
%br
#recap_info_entreprise
= render partial: '/dossiers/infos_entreprise'
%p#insee_infogreffe{style:'color:grey; float:right'}
%i
Informations récupérées auprès de l'INSEE et d'INFOGREFFE
%br
= form_for @facade.dossier, url: { controller: '/users/dossiers', action: :update } do |f|
= f.hidden_field :id
%label{ style:'font-weight:normal' }
= f.check_box :autorisation_donnees
J'autorise les décideurs publics à vérifier les informations de mon organisation 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', disabled: :disabled

View file

@ -0,0 +1,40 @@
.etape.etapes_menu.col-md-3.col-lg-3
%h3
Mes informations
%br
- unless @facade.entreprise.nil?
.center{style:'margin-left: -5%'}
Vous êtes authentifié avec le SIRET
%h3.text-success
= @facade.etablissement.siret
= form_for @facade.dossier, url: users_dossier_change_siret_path(dossier_id: @facade.dossier.id), method: :put, remote: true do |f|
= f.submit 'Changer de SIRET', class: %w(btn btn-xs btn-primary)
.etape.etapes_informations.col-md-9.col-lg-9
.row
- if @facade.entreprise.nil?
#new_siret{style:'margin-left: 20%; margin-top: 5%'}
= form_for @facade.dossier, html: {class: 'form-inline'}, url: users_dossier_siret_informations_path(dossier_id: @facade.dossier.id), method: :post, remote: true do |f|
.form-group.form-group-lg
= f.text_field :siret, class: "form-control", placeholder: "Entrez votre Siret", value: @siret
= f.hidden_field :dossier_id, value: @facade.dossier.id
= f.submit 'Valider', class: %w(btn btn-lg btn-success), data: { disable_with: "Recherche en cours ..." }
- else
%br
#recap_info_entreprise
= render partial: '/dossiers/infos_entreprise'
%p#insee_infogreffe{style:'color:grey; float:right'}
%i
Informations récupérées auprès de l'INSEE et d'INFOGREFFE
%br
= form_for @facade.dossier, url: { controller: '/users/dossiers', action: :update } do |f|
= f.hidden_field :id
%label{ style:'font-weight:normal' }
= f.check_box :autorisation_donnees
J'autorise les décideurs publics à vérifier les informations de mon organisation 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', disabled: :disabled

View file

@ -0,0 +1,40 @@
.etape.etapes_menu.col-md-3.col-lg-3
%h3
Mes informations
%br
%p.center
Les informations de bases
%br
vous concernant.
.etape.etapes_informations.col-md-9.col-lg-9
.row
= form_for @facade.dossier, url: { controller: '/users/dossiers', action: :update } do |f|
= f.hidden_field :id
= f.fields_for :individual, @facade.individual do |ff|
.form-group
%label
%h4
Nom
= ff.text_field :nom, {class: 'form-control'}
.form-group
%label
%h4
Prénom
= ff.text_field :prenom, {class: 'form-control'}
.form-group
%label
%h4
Date de naissance
= ff.text_field :birthdate, {class: 'form-control', 'data-provide' => 'datepicker', 'data-date-format' => 'dd/mm/yyyy'}
%p
%label{ style:'font-weight:normal' }
= f.check_box :autorisation_donnees
= "&nbsp;".html_safe
Vos informations personnelles ne seront jamais utilisées dans un but lucratif ou commercial. Elles ne pourront être communiquées à de tiers personnes sans votre accord préalable. Elles pourront en revanche être communiquées aux administrations compétentes afin d'instruire votre dossier, conformément à la déclaration CNIL effectué par le service TPS.
=link_to 'en savoir plus', cgu_path, target: '_blank'
%br
= f.submit 'Etape suivante', class: "btn btn btn-info", style: 'float:right', id: 'etape_suivante'

View file

@ -0,0 +1,4 @@
%div.center{style:'width: 100%; background-color: white; position: fixed; top:0; left:0; z-index: 100000'}
%h3.text-danger
%b
Votre version d'Internet Explorer est trop ancienne pour être utilisée sur le service TPS. Version minimum : Internet Explorer 10

View file

@ -8,7 +8,6 @@
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= stylesheet_link_tag 'application_split2', media: 'all', 'data-turbolinks-track' => true = stylesheet_link_tag 'application_split2', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true = javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags = csrf_meta_tags
%body %body
@ -16,6 +15,12 @@
%script{type: 'text/javascript'} %script{type: 'text/javascript'}
(typeof jQuery !== 'undefined') && (jQuery.fx.off = true); (typeof jQuery !== 'undefined') && (jQuery.fx.off = true);
="<!--[if lt IE 10]>".html_safe
= render partial: 'layouts/ie_lt_10'
="<![endif]-->".html_safe
%div#wrap %div#wrap
%div#header.navbar %div#header.navbar
=render partial: "layouts/navbar" =render partial: "layouts/navbar"

View file

@ -1,8 +1,8 @@
- unless smart_listing.empty? - unless smart_listing.empty?
%table.table %table.table
%thead %thead
%th.col-md-4.col-lg-4= smart_listing.sortable 'Procédure', 'procedure.libelle' %th.col-md-1.col-lg-1= smart_listing.sortable 'Numéro', 'id'
%th.col-md-4.col-lg-4= smart_listing.sortable 'Raison sociale', 'entreprise.raison_sociale' %th.col-md-5.col-lg-5= smart_listing.sortable 'Procédure', 'procedure.libelle'
%th.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state' %th.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state'
%th.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at' %th.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at'
- @dossiers.each do |dossier| - @dossiers.each do |dossier|
@ -12,11 +12,11 @@
- else - else
- dossier = dossier.decorate - dossier = dossier.decorate
%tr %tr
%td.center
= dossier.id
%td %td
= dossier.procedure.libelle = link_to(dossier.procedure.libelle, users_dossiers_invite_path(id: invite.id)) unless invite.nil?
%td = link_to(dossier.procedure.libelle, users_dossier_recapitulatif_path(dossier)) if invite.nil?
= link_to(dossier.entreprise.raison_sociale, users_dossiers_invite_path(id: invite.id)) unless invite.nil?
= link_to(dossier.entreprise.raison_sociale, users_dossier_recapitulatif_path(dossier)) if invite.nil?
%td{id: "dossier_#{dossier.id}_state"}= dossier.display_state %td{id: "dossier_#{dossier.id}_state"}= dossier.display_state
%td= dossier.last_update %td= dossier.last_update

View file

@ -29,6 +29,7 @@
= devise_error_messages! = devise_error_messages!
#form_login #form_login
%br
= image_tag('logo-tps.png') = image_tag('logo-tps.png')
%br %br
%h2#gestionnaire_login Inscription %h2#gestionnaire_login Inscription

View file

@ -0,0 +1,19 @@
fr:
activerecord:
attributes:
individual:
nom: Nom
prenom: Prénom
birthdate: Date de naissance
errors:
models:
individual:
attributes:
nom:
blank: 'doit être rempli'
prenom:
blank: 'doit être rempli'
birthdate:
blank: 'doit être rempli'

View file

@ -0,0 +1,5 @@
class AddForIndividualAttrInProcedureTable < ActiveRecord::Migration
def change
add_column :procedures, :for_individual, :boolean, default: false
end
end

View file

@ -0,0 +1,11 @@
class CreateIndividualTable < ActiveRecord::Migration
def change
create_table :individuals do |t|
t.string :nom
t.string :prenom
t.string :birthdate
end
add_belongs_to :individuals, :dossier
end
end

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160824094451) do ActiveRecord::Schema.define(version: 20160829114646) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -213,6 +213,13 @@ ActiveRecord::Schema.define(version: 20160824094451) do
add_index "gestionnaires", ["email"], name: "index_gestionnaires_on_email", unique: true, using: :btree add_index "gestionnaires", ["email"], name: "index_gestionnaires_on_email", unique: true, using: :btree
add_index "gestionnaires", ["reset_password_token"], name: "index_gestionnaires_on_reset_password_token", unique: true, using: :btree add_index "gestionnaires", ["reset_password_token"], name: "index_gestionnaires_on_reset_password_token", unique: true, using: :btree
create_table "individuals", force: :cascade do |t|
t.string "nom"
t.string "prenom"
t.string "birthdate"
t.integer "dossier_id"
end
create_table "invites", force: :cascade do |t| create_table "invites", force: :cascade do |t|
t.string "email" t.string "email"
t.string "email_sender" t.string "email_sender"
@ -278,6 +285,7 @@ ActiveRecord::Schema.define(version: 20160824094451) do
t.boolean "published", default: false, null: false t.boolean "published", default: false, null: false
t.string "lien_site_web" t.string "lien_site_web"
t.string "lien_notice" t.string "lien_notice"
t.boolean "for_individual", default: false
end end
create_table "quartier_prioritaires", force: :cascade do |t| create_table "quartier_prioritaires", force: :cascade do |t|

View file

@ -29,5 +29,21 @@ feature 'on backoffice page' do
expect(page).to have_css('#backoffice_dossier_show') expect(page).to have_css('#backoffice_dossier_show')
end end
end end
context 'when gestionnaire have enterprise and individual dossier in his inbox' do
let!(:procedure_individual) { create :procedure, libelle: 'procedure individual', administrateur: administrateur, for_individual: true }
let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'updated' }
before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_individual
visit backoffice_path
page.click_on dossier_individual.id
end
scenario 'it redirect to dossier page' do
expect(page).to have_css('#backoffice_dossier_show')
end
end
end end
end end

View file

@ -9,8 +9,8 @@ feature 'user access to the list of his dossier' do
before do before do
dossier1.update_column(:updated_at, "19/07/2052 15:35".to_time) dossier1.update_column(:updated_at, "19/07/2052 15:35".to_time)
dossier1.entreprise.update_column(:raison_sociale, 'PLOP') dossier1.procedure.update_column(:libelle, 'PLOP')
last_updated_dossier.entreprise.update_column(:raison_sociale, 'PLIP') last_updated_dossier.procedure.update_column(:libelle, 'PLIP')
visit new_user_session_path visit new_user_session_path
within('#new_user') do within('#new_user') do
@ -20,12 +20,12 @@ feature 'user access to the list of his dossier' do
end end
end end
scenario 'the list of dossier is displayed' do scenario 'the list of dossier is displayed' do
expect(page).to have_content(dossier1.entreprise.raison_sociale) expect(page).to have_content(dossier1.procedure.libelle)
expect(page).not_to have_content(dossier2.entreprise.raison_sociale) expect(page).not_to have_content(dossier2.procedure.libelle)
end end
scenario 'the list must be order by last updated' do scenario 'the list must be order by last updated' do
expect(page.body).to match(/#{last_updated_dossier.entreprise.raison_sociale}.*#{dossier1.entreprise.raison_sociale}/m) expect(page.body).to match(/#{last_updated_dossier.procedure.libelle}.*#{dossier1.procedure.libelle}/m)
end end
scenario 'the state of dossier is displayed' do scenario 'the state of dossier is displayed' do
@ -34,7 +34,7 @@ feature 'user access to the list of his dossier' do
context 'when user clicks on a projet in list' do context 'when user clicks on a projet in list' do
before do before do
page.click_on dossier1.entreprise.raison_sociale page.click_on dossier1.procedure.libelle
end end
scenario 'user is redirected to dossier page' do scenario 'user is redirected to dossier page' do
expect(page).to have_css('#recap_dossier') expect(page).to have_css('#recap_dossier')

View file

@ -19,7 +19,7 @@ RSpec.describe NotificationMailer, type: :mailer do
subject(:subject) { described_class.dossier_validated(dossier) } subject(:subject) { described_class.dossier_validated(dossier) }
it { expect(subject.body).to match("Votre dossier N°#{dossier.id} a été validé par votre accompagnateur.") } it { expect(subject.body).to match("Votre dossier N°#{dossier.id} a été validé par votre accompagnateur.") }
it { expect(subject.body).to include("Afin de finaliser son dépot, merci de vous rendre sur #{users_dossier_recapitulatif_url(dossier_id: dossier.id)}") } it { expect(subject.body).to include("Afin de finaliser son dépôt, merci de vous rendre sur #{users_dossier_recapitulatif_url(dossier_id: dossier.id)}") }
it { expect(subject.subject).to eq("Votre dossier TPS N°#{dossier.id} a été validé") } it { expect(subject.subject).to eq("Votre dossier TPS N°#{dossier.id} a été validé") }
end end
@ -30,7 +30,7 @@ RSpec.describe NotificationMailer, type: :mailer do
subject(:subject) { described_class.dossier_submitted(dossier) } subject(:subject) { described_class.dossier_submitted(dossier) }
it { expect(subject.body).to match("Nous vous confirmons que votre dossier N°#{dossier.id} a été déposé") } it { expect(subject.body).to match("Nous vous confirmons que votre dossier N°#{dossier.id} a été déposé") }
it { expect(subject.body).to match("aurpès de #{dossier.procedure.organisation} avec succès") } it { expect(subject.body).to match("auprès de #{dossier.procedure.organisation} avec succès") }
it { expect(subject.body).to match("ce jour à #{dossier.updated_at}.") } it { expect(subject.body).to match("ce jour à #{dossier.updated_at}.") }
it { expect(subject.subject).to eq("Votre dossier TPS N°#{dossier.id} a été déposé") } it { expect(subject.subject).to eq("Votre dossier TPS N°#{dossier.id} a été déposé") }
end end

View file

@ -23,6 +23,7 @@ describe Dossier do
it { is_expected.to have_many(:cerfa) } it { is_expected.to have_many(:cerfa) }
it { is_expected.to have_one(:etablissement) } it { is_expected.to have_one(:etablissement) }
it { is_expected.to have_one(:entreprise) } it { is_expected.to have_one(:entreprise) }
it { is_expected.to have_one(:individual) }
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
it { is_expected.to have_many(:invites) } it { is_expected.to have_many(:invites) }
it { is_expected.to have_many(:follows) } it { is_expected.to have_many(:follows) }
@ -105,6 +106,24 @@ describe Dossier do
end end
end end
describe '#build_default_individual' do
context 'when dossier is linked to a procedure with for_individual attr false' do
let(:dossier) { create(:dossier, user: user) }
it 'have no object created' do
expect(dossier.individual).to be_nil
end
end
context 'when dossier is linked to a procedure with for_individual attr true' do
let(:dossier) { create(:dossier, user: user, procedure: (create :procedure, for_individual: true)) }
it 'have no object created' do
expect(dossier.individual).not_to be_nil
end
end
end
describe '#save' do describe '#save' do
subject { build(:dossier, procedure: procedure, user: user) } subject { build(:dossier, procedure: procedure, user: user) }
let!(:procedure) { create(:procedure) } let!(:procedure) { create(:procedure) }

View file

@ -0,0 +1,8 @@
require 'spec_helper'
describe Individual do
it { is_expected.to have_db_column(:nom) }
it { is_expected.to have_db_column(:prenom) }
it { is_expected.to have_db_column(:birthdate) }
it { is_expected.to belong_to(:dossier) }
end

View file

@ -15,15 +15,6 @@ describe 'users/dossiers/index.html.haml', type: :view do
let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'initiated').decorate } let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'initiated').decorate }
before do before do
decorate_dossier_replied.entreprise.update_column(:raison_sociale, 'plap')
decorate_dossier_updated.entreprise.update_column(:raison_sociale, 'plep')
decorate_dossier_validated.entreprise.update_column(:raison_sociale, 'plip')
decorate_dossier_submitted.entreprise.update_column(:raison_sociale, 'plop')
decorate_dossier_received.entreprise.update_column(:raison_sociale, 'plup')
decorate_dossier_closed.entreprise.update_column(:raison_sociale, 'plyp')
decorate_dossier_refused.entreprise.update_column(:raison_sociale, 'plzp')
decorate_dossier_without_continuation.entreprise.update_column(:raison_sociale, 'plnp')
create :invite, dossier: decorate_dossier_invite, user: user create :invite, dossier: decorate_dossier_invite, user: user
end end
@ -42,8 +33,8 @@ describe 'users/dossiers/index.html.haml', type: :view do
subject { rendered } subject { rendered }
describe 'columns' do describe 'columns' do
it { is_expected.to have_content(decorate_dossier_at_check.id) }
it { is_expected.to have_content(decorate_dossier_at_check.procedure.libelle) } it { is_expected.to have_content(decorate_dossier_at_check.procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_at_check.entreprise.raison_sociale) }
it { is_expected.to have_content(decorate_dossier_at_check.display_state) } it { is_expected.to have_content(decorate_dossier_at_check.display_state) }
it { is_expected.to have_content(decorate_dossier_at_check.last_update) } it { is_expected.to have_content(decorate_dossier_at_check.last_update) }
end end