REFACTOR : Change dossier state 'Proposed' To 'Submitted'

This commit is contained in:
Xavier J 2015-11-02 11:23:55 +01:00
parent 0e8919a523
commit c0733849d5
19 changed files with 54 additions and 49 deletions

View file

@ -45,7 +45,7 @@ class Users::DescriptionController < UsersController
commentaire.dossier = @dossier
commentaire.save
else
@dossier.proposed!
@dossier.submitted!
end
flash.notice = 'Félicitation, votre demande a bien été enregistrée.'

View file

@ -16,10 +16,10 @@ class Users::RecapitulatifController < UsersController
redirect_to url_for(root_path)
end
def propose
def submit
show
@dossier.next_step! 'user', 'propose'
@dossier.next_step! 'user', 'submit'
flash.notice = 'Dossier soumis avec succès.'
render 'show'

View file

@ -15,7 +15,7 @@ class DossierDecorator < Draper::Decorator
case state
when 'draft'
'Brouillon'
when 'proposed'
when 'submitted'
'Soumis'
when 'reply'
'Répondu'

View file

@ -1,11 +1,11 @@
class Dossier < ActiveRecord::Base
enum state: {draft: 'draft',
proposed: 'proposed',
reply: 'reply',
submitted: 'submitted', #-proposed
reply: 'reply', #replied
updated: 'updated',
confirmed: 'confirmed',
deposited: 'deposited',
processed: 'processed' }
confirmed: 'confirmed', #validated
deposited: 'deposited', #submit_confirmed
processed: 'processed'} #closed
has_one :etablissement, dependent: :destroy
has_one :entreprise, dependent: :destroy
@ -49,7 +49,7 @@ class Dossier < ActiveRecord::Base
end
def next_step! role, action
unless %w(propose reply update comment confirme depose process).include?(action)
unless %w(submit reply update comment confirme depose process).include?(action)
fail 'action is not valid'
end
@ -59,9 +59,9 @@ class Dossier < ActiveRecord::Base
if role == 'user'
case action
when 'propose'
when 'submit'
if draft?
proposed!
submitted!
end
when 'depose'
if confirmed?
@ -81,7 +81,7 @@ class Dossier < ActiveRecord::Base
when 'comment'
if updated?
reply!
elsif proposed?
elsif submitted?
reply!
end
when 'confirme'
@ -89,7 +89,7 @@ class Dossier < ActiveRecord::Base
confirmed!
elsif reply?
confirmed!
elsif proposed?
elsif submitted?
confirmed!
end
when 'process'
@ -102,7 +102,7 @@ class Dossier < ActiveRecord::Base
end
def self.a_traiter
Dossier.where("state='proposed' OR state='updated' OR state='deposited'").order('updated_at ASC')
Dossier.where("state='submitted' OR state='updated' OR state='deposited'").order('updated_at ASC')
end
def self.en_attente

View file

@ -11,7 +11,7 @@
- unless gestionnaire_signed_in?
-if @dossier.draft?
= form_tag(url_for({controller: :recapitulatif, action: :propose, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
= form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success
= 'Soumettre mon dossier'
-elsif @dossier.confirmed?

View file

@ -26,7 +26,7 @@ Rails.application.routes.draw do
get '/description/error' => 'description#error'
post 'description' => 'description#create'
get '/recapitulatif' => 'recapitulatif#show'
post '/recapitulatif/propose' => 'recapitulatif#propose'
post '/recapitulatif/submit' => 'recapitulatif#submit'
post '/recapitulatif/depose' => 'recapitulatif#depose'
# get '/demande' => 'demandes#show'
# post '/demande' => 'demandes#update'

View file

@ -0,0 +1,5 @@
class ChangeStateProposedToSubmitted < ActiveRecord::Migration
def change
Dossier.where(state: 'proposed').update_all(state: 'submitted')
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151027150850) do
ActiveRecord::Schema.define(version: 20151102101616) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

View file

@ -32,7 +32,7 @@ describe Backoffice::DossiersController, type: :controller do
describe 'POST #confirme' do
context 'le gestionnaire valide un dossier' do
before do
dossier.proposed!
dossier.submitted!
sign_in gestionnaire
end

View file

@ -49,7 +49,7 @@ RSpec.describe Users::CarteController, type: :controller do
end
context 'En train de modifier la localisation' do
let(:dossier) { create(:dossier, :with_procedure, :with_user, ref_dossier_carto: ref_dossier_carto, state: 'proposed') }
let(:dossier) { create(:dossier, :with_procedure, :with_user, ref_dossier_carto: ref_dossier_carto, state: 'submitted') }
before do
post :save_ref_api_carto, dossier_id: dossier_id, ref_dossier_carto: ref_dossier_carto
end

View file

@ -65,14 +65,14 @@ describe Users::DescriptionController, type: :controller do
end
it 'etat du dossier est soumis' do
expect(dossier.state).to eq('proposed')
expect(dossier.state).to eq('submitted')
end
end
# TODO changer les valeurs des champs et check in bdd
context 'En train de manipuler un dossier non brouillon' do
before do
dossier.proposed!
dossier.submitted!
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle
dossier.reload
end

View file

@ -23,18 +23,18 @@ describe Users::RecapitulatifController, type: :controller do
end
describe 'POST #propose' do
context 'when an user propose his dossier' do
describe 'POST #submit' do
context 'when an user submit his dossier' do
before do
post :propose, dossier_id: dossier.id
post :submit, dossier_id: dossier.id
end
it 'dossier change his state for processed' do
dossier.reload
expect(dossier.state).to eq('proposed')
expect(dossier.state).to eq('submitted')
end
it 'a message informe user what his dossier is proposed' do
it 'a message informe user what his dossier is submitted' do
expect(flash[:notice]).to include('Dossier soumis avec succès.')
end
end
@ -52,7 +52,7 @@ describe Users::RecapitulatifController, type: :controller do
expect(dossier.state).to eq('deposited')
end
it 'a message informe user what his dossier is proposed' do
it 'a message informe user what his dossier is submitted' do
expect(flash[:notice]).to include('Dossier déposé avec succès.')
end
end

View file

@ -17,8 +17,8 @@ describe DossierDecorator do
expect(subject).to eq('Brouillon')
end
it 'proposed is propose' do
dossier.proposed!
it 'submitted is submit' do
dossier.submitted!
expect(subject).to eq('Soumis')
end

View file

@ -122,7 +122,7 @@ describe Dossier do
describe '#next_step' do
let(:dossier) { create(:dossier, :with_user) }
let(:role) { 'user' }
let(:action) { 'propose' }
let(:action) { 'submit' }
subject { dossier.next_step! role, action }
@ -156,17 +156,17 @@ describe Dossier do
it { is_expected.to eq('draft') }
end
context 'when he proposes a dossier' do
let(:action) { 'propose' }
context 'when he submit a dossier' do
let(:action) { 'submit' }
it { is_expected.to eq('proposed') }
it { is_expected.to eq('submitted') }
end
end
end
context 'when dossier is at state proposed' do
context 'when dossier is at state submitted' do
before do
dossier.proposed!
dossier.submitted!
end
context 'when user is connect' do
@ -175,13 +175,13 @@ describe Dossier do
context 'when is update dossier informations' do
let(:action) { 'update' }
it {is_expected.to eq('proposed')}
it {is_expected.to eq('submitted')}
end
context 'when is post a comment' do
let(:action) { 'comment' }
it {is_expected.to eq('proposed')}
it {is_expected.to eq('submitted')}
end
end
@ -373,8 +373,8 @@ describe Dossier do
context 'gestionnaire backoffice methods' do
let!(:dossier1) { create(:dossier, :with_user, :with_procedure, state: 'draft')}
let!(:dossier2) { create(:dossier, :with_user, :with_procedure, state: 'proposed')}
let!(:dossier3) { create(:dossier, :with_user, :with_procedure, state: 'proposed')}
let!(:dossier2) { create(:dossier, :with_user, :with_procedure, state: 'submitted')}
let!(:dossier3) { create(:dossier, :with_user, :with_procedure, state: 'submitted')}
let!(:dossier4) { create(:dossier, :with_user, :with_procedure, state: 'reply')}
let!(:dossier5) { create(:dossier, :with_user, :with_procedure, state: 'updated')}
let!(:dossier6) { create(:dossier, :with_user, :with_procedure, state: 'confirmed')}

View file

@ -47,9 +47,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
end
context 'gestion des etats du dossier' do
context 'when dossier have state proposed' do
context 'when dossier have state submitted' do
before do
dossier.proposed!
dossier.submitted!
render
end

View file

@ -8,7 +8,7 @@ describe 'backoffice/index.html.haml', type: :view do
assign(:dossiers_en_attente, Dossier.en_attente.decorate)
assign(:dossiers_termine, Dossier.termine.decorate)
decorate_dossier.proposed!
decorate_dossier.submitted!
render
end
subject { rendered }

View file

@ -46,7 +46,7 @@ describe 'users/carte/show.html.haml', type: :view do
end
context 'si la page précédente est recapitularif' do
let(:state) { 'proposed' }
let(:state) { 'submitted' }
it 'le bouton "Etape suivante" n\'est pas présent' do
expect(rendered).to_not have_selector('#etape_suivante')

View file

@ -70,7 +70,7 @@ describe 'users/description/show.html.haml', type: :view do
context 'si la page précédente est recapitularif' do
before do
dossier.proposed!
dossier.submitted!
dossier.reload
render
end

View file

@ -55,9 +55,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
end
end
context 'when dossier state is proposed' do
context 'when dossier state is submitted' do
before do
dossier.proposed!
dossier.submitted!
render
end