ajout de la procédure à la création d'un dossier
This commit is contained in:
parent
632c19bc48
commit
94cfa8a139
3 changed files with 27 additions and 44 deletions
|
@ -14,7 +14,8 @@ class DossiersController < ApplicationController
|
||||||
@entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
|
@entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
|
||||||
@dossier = Dossier.create
|
@dossier = Dossier.create
|
||||||
|
|
||||||
@dossier.procedure_id
|
@dossier.procedure = Procedure.find(params['procedure_id'])
|
||||||
|
@dossier.save
|
||||||
|
|
||||||
@entreprise.dossier = @dossier
|
@entreprise.dossier = @dossier
|
||||||
@entreprise.save
|
@entreprise.save
|
||||||
|
|
32
db/schema.rb
32
db/schema.rb
|
@ -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: 20150922082416) do
|
ActiveRecord::Schema.define(version: 20150922085811) 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"
|
||||||
|
@ -34,19 +34,21 @@ ActiveRecord::Schema.define(version: 20150922082416) do
|
||||||
add_index "commentaires", ["dossier_id"], name: "index_commentaires_on_dossier_id", using: :btree
|
add_index "commentaires", ["dossier_id"], name: "index_commentaires_on_dossier_id", using: :btree
|
||||||
|
|
||||||
create_table "dossiers", force: :cascade do |t|
|
create_table "dossiers", force: :cascade do |t|
|
||||||
t.string "description"
|
t.string "description"
|
||||||
t.boolean "autorisation_donnees"
|
t.boolean "autorisation_donnees"
|
||||||
t.string "position_lat"
|
t.string "position_lat"
|
||||||
t.string "position_lon"
|
t.string "position_lon"
|
||||||
t.string "ref_dossier"
|
t.string "ref_dossier"
|
||||||
t.string "nom_projet"
|
t.string "nom_projet"
|
||||||
t.string "montant_projet"
|
t.string "montant_projet"
|
||||||
t.string "montant_aide_demande"
|
t.string "montant_aide_demande"
|
||||||
t.string "lien_plus_infos"
|
t.string "lien_plus_infos"
|
||||||
t.string "mail_contact"
|
t.string "mail_contact"
|
||||||
t.boolean "dossier_termine"
|
t.boolean "dossier_termine"
|
||||||
t.integer "procedure_id"
|
t.integer "procedure_id"
|
||||||
t.date "date_previsionnelle"
|
t.date "date_previsionnelle"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
|
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
|
||||||
|
@ -108,7 +110,7 @@ ActiveRecord::Schema.define(version: 20150922082416) do
|
||||||
t.integer "type_de_piece_justificative_id"
|
t.integer "type_de_piece_justificative_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "pieces_justificatives", ["type_de_piece_justificative_id"], name: "index_pieces_justificatives_on_type_de_piece_justificative_id", using: :btree
|
add_index "pieces_justificatives", ["type_de_piece_justificative_id"], name: "index_pieces_justificatives_on_type_piece_jointe_id", using: :btree
|
||||||
|
|
||||||
create_table "procedures", force: :cascade do |t|
|
create_table "procedures", force: :cascade do |t|
|
||||||
t.string "libelle"
|
t.string "libelle"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
RSpec.describe DossiersController, type: :controller do
|
RSpec.describe DossiersController, type: :controller do
|
||||||
let(:dossier) { create(:dossier, :with_entreprise) }
|
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:siret_not_found) { 999_999_999_999 }
|
let(:siret_not_found) { 999_999_999_999 }
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ RSpec.describe DossiersController, type: :controller do
|
||||||
context 'when pro_dossier_id is empty' do
|
context 'when pro_dossier_id is empty' do
|
||||||
context 'with valid siret ' do
|
context 'with valid siret ' do
|
||||||
before do
|
before do
|
||||||
post :create, siret: siret, pro_dossier_id: ''
|
post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'create a dossier' do
|
it 'create a dossier' do
|
||||||
|
@ -45,7 +45,7 @@ RSpec.describe DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates entreprise' do
|
it 'creates entreprise' do
|
||||||
expect { post :create, siret: siret, pro_dossier_id: '' }.to change { Entreprise.count }.by(1)
|
expect { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }.to change { Entreprise.count }.by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'links entreprise to dossier' do
|
it 'links entreprise to dossier' do
|
||||||
|
@ -53,7 +53,7 @@ RSpec.describe DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates etablissement for dossier' do
|
it 'creates etablissement for dossier' do
|
||||||
expect { post :create, siret: siret, pro_dossier_id: '' }.to change { Etablissement.count }.by(1)
|
expect { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }.to change { Etablissement.count }.by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'links etablissement to dossier' do
|
it 'links etablissement to dossier' do
|
||||||
|
@ -63,6 +63,10 @@ RSpec.describe DossiersController, type: :controller do
|
||||||
it 'links etablissement to entreprise' do
|
it 'links etablissement to entreprise' do
|
||||||
expect(Etablissement.last.entreprise).to eq(Entreprise.last)
|
expect(Etablissement.last.entreprise).to eq(Entreprise.last)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'links procedure to dossier' do
|
||||||
|
expect(Dossier.last.procedure).to eq(Procedure.last)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with non existant siret' do
|
context 'with non existant siret' do
|
||||||
|
@ -77,30 +81,6 @@ RSpec.describe DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# context 'when pro_dossier_id is not empty' do
|
|
||||||
# let!(:dossier) { create(:dossier, :with_entreprise) }
|
|
||||||
# subject { post :create, siret: dossier.siret, pro_dossier_id: 99_999_999_999 }
|
|
||||||
#
|
|
||||||
# context 'when dossier not found' do
|
|
||||||
# it 'redirects to start with error_dossier' do
|
|
||||||
# expect(subject).to redirect_to(controller: :start, action: :error_dossier)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# context 'when dossier found' do
|
|
||||||
# context 'when siret match' do
|
|
||||||
# subject { post :create, siret: dossier.siret, pro_dossier_id: dossier.id }
|
|
||||||
# it 'redirects to controller recapitulatif' do
|
|
||||||
# expect(subject).to redirect_to(controller: :recapitulatif, action: :show, dossier_id: dossier.id)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# context 'when siret does not match' do
|
|
||||||
# subject { post :create, siret: '11111111111111', pro_dossier_id: dossier.id }
|
|
||||||
# it 'redirects to start with action error_dossier' do
|
|
||||||
# expect(subject).to redirect_to(controller: :start, action: :error_dossier)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue