REFACTOR: Change dossier state 'Reply' To 'Replied'
This commit is contained in:
parent
c0733849d5
commit
4a05af89fc
11 changed files with 32 additions and 27 deletions
|
@ -17,7 +17,7 @@ class DossierDecorator < Draper::Decorator
|
||||||
'Brouillon'
|
'Brouillon'
|
||||||
when 'submitted'
|
when 'submitted'
|
||||||
'Soumis'
|
'Soumis'
|
||||||
when 'reply'
|
when 'replied'
|
||||||
'Répondu'
|
'Répondu'
|
||||||
when 'updated'
|
when 'updated'
|
||||||
'Mis à jour'
|
'Mis à jour'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class Dossier < ActiveRecord::Base
|
class Dossier < ActiveRecord::Base
|
||||||
enum state: {draft: 'draft',
|
enum state: {draft: 'draft',
|
||||||
submitted: 'submitted', #-proposed
|
submitted: 'submitted',
|
||||||
reply: 'reply', #replied
|
replied: 'replied', #replied
|
||||||
updated: 'updated',
|
updated: 'updated',
|
||||||
confirmed: 'confirmed', #validated
|
confirmed: 'confirmed', #validated
|
||||||
deposited: 'deposited', #submit_confirmed
|
deposited: 'deposited', #submit_confirmed
|
||||||
|
@ -49,7 +49,7 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_step! role, action
|
def next_step! role, action
|
||||||
unless %w(submit reply update comment confirme depose process).include?(action)
|
unless %w(submit replied update comment confirme depose process).include?(action)
|
||||||
fail 'action is not valid'
|
fail 'action is not valid'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,11 +68,11 @@ class Dossier < ActiveRecord::Base
|
||||||
deposited!
|
deposited!
|
||||||
end
|
end
|
||||||
when 'update'
|
when 'update'
|
||||||
if reply?
|
if replied?
|
||||||
updated!
|
updated!
|
||||||
end
|
end
|
||||||
when 'comment'
|
when 'comment'
|
||||||
if reply?
|
if replied?
|
||||||
updated!
|
updated!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -80,14 +80,14 @@ class Dossier < ActiveRecord::Base
|
||||||
case action
|
case action
|
||||||
when 'comment'
|
when 'comment'
|
||||||
if updated?
|
if updated?
|
||||||
reply!
|
replied!
|
||||||
elsif submitted?
|
elsif submitted?
|
||||||
reply!
|
replied!
|
||||||
end
|
end
|
||||||
when 'confirme'
|
when 'confirme'
|
||||||
if updated?
|
if updated?
|
||||||
confirmed!
|
confirmed!
|
||||||
elsif reply?
|
elsif replied?
|
||||||
confirmed!
|
confirmed!
|
||||||
elsif submitted?
|
elsif submitted?
|
||||||
confirmed!
|
confirmed!
|
||||||
|
@ -106,7 +106,7 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.en_attente
|
def self.en_attente
|
||||||
Dossier.where("state='reply' OR state='confirmed'").order('updated_at ASC')
|
Dossier.where("state='replied' OR state='confirmed'").order('updated_at ASC')
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.termine
|
def self.termine
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeStatereplyToReplied < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
Dossier.where(state: 'reply').update_all(state: 'replied')
|
||||||
|
end
|
||||||
|
end
|
|
@ -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: 20151102101616) do
|
ActiveRecord::Schema.define(version: 20151102102747) 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"
|
||||||
|
|
|
@ -30,7 +30,7 @@ describe Backoffice::CommentairesController, type: :controller do
|
||||||
|
|
||||||
subject { dossier.state }
|
subject { dossier.state }
|
||||||
|
|
||||||
it {is_expected.to eq('reply')}
|
it {is_expected.to eq('replied')}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,10 +17,10 @@ describe Users::CommentairesController, type: :controller do
|
||||||
|
|
||||||
describe 'change dossier state after post a comment' do
|
describe 'change dossier state after post a comment' do
|
||||||
context 'when user is connected' do
|
context 'when user is connected' do
|
||||||
context 'when dossier is at state reply' do
|
context 'when dossier is at state replied' do
|
||||||
before do
|
before do
|
||||||
sign_in dossier.user
|
sign_in dossier.user
|
||||||
dossier.reply!
|
dossier.replied!
|
||||||
|
|
||||||
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
||||||
dossier.reload
|
dossier.reload
|
||||||
|
|
|
@ -22,8 +22,8 @@ describe DossierDecorator do
|
||||||
expect(subject).to eq('Soumis')
|
expect(subject).to eq('Soumis')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'reply is repondu' do
|
it 'replied is repondu' do
|
||||||
dossier.reply!
|
dossier.replied!
|
||||||
expect(subject).to eq('Répondu')
|
expect(subject).to eq('Répondu')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
feature 'on backoffice page' do
|
feature 'on backoffice page' do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let!(:dossier) { create(:dossier, :with_user, :with_entreprise, procedure: procedure, state: 'reply') }
|
let!(:dossier) { create(:dossier, :with_user, :with_entreprise, procedure: procedure, state: 'replied') }
|
||||||
before do
|
before do
|
||||||
visit backoffice_path
|
visit backoffice_path
|
||||||
end
|
end
|
||||||
|
|
|
@ -191,7 +191,7 @@ describe Dossier do
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it { is_expected.to eq('reply')}
|
it { is_expected.to eq('replied')}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is confirmed the dossier' do
|
context 'when is confirmed the dossier' do
|
||||||
|
@ -202,9 +202,9 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier is at state reply' do
|
context 'when dossier is at state replied' do
|
||||||
before do
|
before do
|
||||||
dossier.reply!
|
dossier.replied!
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is connect' do
|
context 'when user is connect' do
|
||||||
|
@ -232,7 +232,7 @@ describe Dossier do
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it { is_expected.to eq('reply')}
|
it { is_expected.to eq('replied')}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is confirmed the dossier' do
|
context 'when is confirmed the dossier' do
|
||||||
|
@ -270,7 +270,7 @@ describe Dossier do
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it { is_expected.to eq('reply')}
|
it { is_expected.to eq('replied')}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is confirmed the dossier' do
|
context 'when is confirmed the dossier' do
|
||||||
|
@ -375,7 +375,7 @@ describe Dossier do
|
||||||
let!(:dossier1) { create(:dossier, :with_user, :with_procedure, state: 'draft')}
|
let!(:dossier1) { create(:dossier, :with_user, :with_procedure, state: 'draft')}
|
||||||
let!(:dossier2) { create(:dossier, :with_user, :with_procedure, state: 'submitted')}
|
let!(:dossier2) { create(:dossier, :with_user, :with_procedure, state: 'submitted')}
|
||||||
let!(:dossier3) { 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!(:dossier4) { create(:dossier, :with_user, :with_procedure, state: 'replied')}
|
||||||
let!(:dossier5) { create(:dossier, :with_user, :with_procedure, state: 'updated')}
|
let!(:dossier5) { create(:dossier, :with_user, :with_procedure, state: 'updated')}
|
||||||
let!(:dossier6) { create(:dossier, :with_user, :with_procedure, state: 'confirmed')}
|
let!(:dossier6) { create(:dossier, :with_user, :with_procedure, state: 'confirmed')}
|
||||||
let!(:dossier7) { create(:dossier, :with_user, :with_procedure, state: 'deposited')}
|
let!(:dossier7) { create(:dossier, :with_user, :with_procedure, state: 'deposited')}
|
||||||
|
|
|
@ -61,9 +61,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier have state reply' do
|
context 'when dossier have state replied' do
|
||||||
before do
|
before do
|
||||||
dossier.reply!
|
dossier.replied!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
||||||
it { expect(rendered).to have_content('Soumis') }
|
it { expect(rendered).to have_content('Soumis') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier state is reply' do
|
context 'when dossier state is replied' do
|
||||||
before do
|
before do
|
||||||
dossier.reply!
|
dossier.replied!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue