Merge branch 'develop' of ssh://37.187.249.111:2200/opt/git/tps into develop
Conflicts: db/schema.rb
This commit is contained in:
commit
9da4a33e62
6 changed files with 37 additions and 30 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
|
||||||
|
|
|
@ -2,4 +2,8 @@ class Procedure < ActiveRecord::Base
|
||||||
has_many :types_de_piece_justificative
|
has_many :types_de_piece_justificative
|
||||||
has_many :dossiers
|
has_many :dossiers
|
||||||
belongs_to :evenement_vie
|
belongs_to :evenement_vie
|
||||||
|
|
||||||
|
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||||
|
validates :description, presence: true, allow_blank: false, allow_nil: false
|
||||||
|
validates :lien_demarche, presence: true, allow_blank: false, allow_nil: false
|
||||||
end
|
end
|
||||||
|
|
|
@ -110,7 +110,7 @@ ActiveRecord::Schema.define(version: 20150922085811) 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
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :procedure do
|
factory :procedure do
|
||||||
|
libelle 'Demande de subvention'
|
||||||
|
description 'Description demande de subvention'
|
||||||
lien_demarche 'http://localhost'
|
lien_demarche 'http://localhost'
|
||||||
libelle 'Demande de subvention'
|
libelle 'Demande de subvention'
|
||||||
description "Demande de subvention à l'intention des associations"
|
description "Demande de subvention à l'intention des associations"
|
||||||
|
|
|
@ -13,4 +13,24 @@ describe Procedure do
|
||||||
it { is_expected.to have_db_column(:direction) }
|
it { is_expected.to have_db_column(:direction) }
|
||||||
it { is_expected.to have_db_column(:test) }
|
it { is_expected.to have_db_column(:test) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'validation' do
|
||||||
|
context 'libelle' do
|
||||||
|
it { is_expected.not_to allow_value(nil).for(:libelle) }
|
||||||
|
it { is_expected.not_to allow_value('').for(:libelle) }
|
||||||
|
it { is_expected.to allow_value('Demande de subvention').for(:libelle) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'description' do
|
||||||
|
it { is_expected.not_to allow_value(nil).for(:description) }
|
||||||
|
it { is_expected.not_to allow_value('').for(:description) }
|
||||||
|
it { is_expected.to allow_value('Description Demande de subvention').for(:description) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'lien_demarche' do
|
||||||
|
it { is_expected.not_to allow_value(nil).for(:lien_demarche) }
|
||||||
|
it { is_expected.not_to allow_value('').for(:lien_demarche) }
|
||||||
|
it { is_expected.to allow_value('http://localhost').for(:lien_demarche) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue