Add deposit date time on dossier table
This commit is contained in:
parent
d6b9ebde9a
commit
9487d47ef8
5 changed files with 24 additions and 7 deletions
|
@ -19,11 +19,9 @@ class Users::RecapitulatifController < UsersController
|
|||
def submit
|
||||
create_dossier_facade
|
||||
|
||||
@facade.dossier.next_step! 'user', 'submit'
|
||||
@facade.dossier.submit!
|
||||
flash.notice = 'Dossier déposé avec succès.'
|
||||
|
||||
NotificationMailer.dossier_submitted(@facade.dossier).deliver_now!
|
||||
|
||||
render 'show'
|
||||
end
|
||||
|
||||
|
|
|
@ -216,4 +216,11 @@ class Dossier < ActiveRecord::Base
|
|||
def total_commentaire
|
||||
self.commentaires.size
|
||||
end
|
||||
|
||||
def submit!
|
||||
self.deposit_datetime= DateTime.now
|
||||
|
||||
next_step! 'user', 'submit'
|
||||
NotificationMailer.dossier_submitted(self).deliver_now!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddDepositAttrInDossierTable < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :dossiers, :deposit_datetime, :datetime
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160804130638) do
|
||||
ActiveRecord::Schema.define(version: 20160808115924) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -124,6 +124,7 @@ ActiveRecord::Schema.define(version: 20160804130638) do
|
|||
t.text "json_latlngs"
|
||||
t.boolean "archived", default: false
|
||||
t.boolean "mandataire_social", default: false
|
||||
t.datetime "deposit_datetime"
|
||||
end
|
||||
|
||||
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::RecapitulatifController, type: :controller do
|
||||
let(:dossier) { create(:dossier, state:'initiated') }
|
||||
let(:dossier) { create(:dossier, state: 'initiated') }
|
||||
let(:bad_dossier_id) { Dossier.count + 100000 }
|
||||
|
||||
before do
|
||||
|
@ -55,16 +55,22 @@ describe Users::RecapitulatifController, type: :controller do
|
|||
|
||||
describe 'POST #submit' do
|
||||
context 'when an user depose his dossier' do
|
||||
let(:deposit_datetime) { Time.local(2016, 8, 1, 10, 5, 0) }
|
||||
|
||||
before do
|
||||
dossier.validated!
|
||||
post :submit, dossier_id: dossier.id
|
||||
Timecop.freeze(deposit_datetime) { post :submit, dossier_id: dossier.id }
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it 'dossier change his state for submitted' do
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('submitted')
|
||||
end
|
||||
|
||||
it 'dossier deposit datetime is filled' do
|
||||
expect(dossier.deposit_datetime).to eq deposit_datetime
|
||||
end
|
||||
|
||||
it 'a message informe user what his dossier is initiated' do
|
||||
expect(flash[:notice]).to include('Dossier déposé avec succès.')
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue