Merge branch 'develop' of ssh://37.187.249.111:2200/opt/git/tps into develop

Conflicts:
	db/schema.rb
This commit is contained in:
Tanguy PATTE 2015-09-23 10:02:54 +02:00
commit ca363ca095
6 changed files with 21 additions and 4 deletions

View file

@ -9,10 +9,10 @@ class DossiersController < ApplicationController
end end
def create def create
@etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params) @etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
@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.draft!
@dossier.procedure = Procedure.find(params['procedure_id']) @dossier.procedure = Procedure.find(params['procedure_id'])
@dossier.save @dossier.save

View file

@ -1,4 +1,12 @@
class Dossier < ActiveRecord::Base class Dossier < ActiveRecord::Base
enum state: { draft: 'draft',
submitted: 'submitted',
reply: 'reply',
updated: 'updated',
confirmed: 'confirmed',
filed: 'filed',
processed: 'processed' }
has_one :etablissement has_one :etablissement
has_one :entreprise has_one :entreprise
has_one :cerfa has_one :cerfa
@ -45,5 +53,4 @@ class Dossier < ActiveRecord::Base
build_cerfa build_cerfa
true true
end end
end end

View file

@ -0,0 +1,6 @@
class AddStateToDossier < ActiveRecord::Migration
def change
remove_column :dossiers, :dossier_termine
add_column :dossiers, :state, :string
end
end

View file

@ -11,6 +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: 20150922141232) do ActiveRecord::Schema.define(version: 20150922141232) 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
@ -42,11 +43,11 @@ ActiveRecord::Schema.define(version: 20150922141232) do
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.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 "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "state"
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

View file

@ -67,6 +67,10 @@ RSpec.describe DossiersController, type: :controller do
it 'links procedure to dossier' do it 'links procedure to dossier' do
expect(Dossier.last.procedure).to eq(Procedure.last) expect(Dossier.last.procedure).to eq(Procedure.last)
end end
it 'state of dossier is draft' do
expect(Dossier.last.state).to eq('draft')
end
end end
context 'with non existant siret' do context 'with non existant siret' do

View file

@ -10,7 +10,6 @@ describe Dossier do
it { is_expected.to have_db_column(:montant_projet) } it { is_expected.to have_db_column(:montant_projet) }
it { is_expected.to have_db_column(:montant_aide_demande) } it { is_expected.to have_db_column(:montant_aide_demande) }
it { is_expected.to have_db_column(:date_previsionnelle).of_type(:date) } it { is_expected.to have_db_column(:date_previsionnelle).of_type(:date) }
it { is_expected.to have_db_column(:dossier_termine) }
it { is_expected.to have_db_column(:created_at) } it { is_expected.to have_db_column(:created_at) }
it { is_expected.to have_db_column(:updated_at) } it { is_expected.to have_db_column(:updated_at) }
end end