REFACTOR: Change dossier state 'Reply' To 'Replied'

This commit is contained in:
Xavier J 2015-11-02 11:33:00 +01:00
parent c0733849d5
commit 4a05af89fc
11 changed files with 32 additions and 27 deletions

View file

@ -17,7 +17,7 @@ class DossierDecorator < Draper::Decorator
'Brouillon'
when 'submitted'
'Soumis'
when 'reply'
when 'replied'
'Répondu'
when 'updated'
'Mis à jour'

View file

@ -1,7 +1,7 @@
class Dossier < ActiveRecord::Base
enum state: {draft: 'draft',
submitted: 'submitted', #-proposed
reply: 'reply', #replied
submitted: 'submitted',
replied: 'replied', #replied
updated: 'updated',
confirmed: 'confirmed', #validated
deposited: 'deposited', #submit_confirmed
@ -49,7 +49,7 @@ class Dossier < ActiveRecord::Base
end
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'
end
@ -68,11 +68,11 @@ class Dossier < ActiveRecord::Base
deposited!
end
when 'update'
if reply?
if replied?
updated!
end
when 'comment'
if reply?
if replied?
updated!
end
end
@ -80,14 +80,14 @@ class Dossier < ActiveRecord::Base
case action
when 'comment'
if updated?
reply!
replied!
elsif submitted?
reply!
replied!
end
when 'confirme'
if updated?
confirmed!
elsif reply?
elsif replied?
confirmed!
elsif submitted?
confirmed!
@ -106,7 +106,7 @@ class Dossier < ActiveRecord::Base
end
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
def self.termine

View file

@ -0,0 +1,5 @@
class ChangeStatereplyToReplied < ActiveRecord::Migration
def change
Dossier.where(state: 'reply').update_all(state: 'replied')
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: 20151102101616) do
ActiveRecord::Schema.define(version: 20151102102747) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

View file

@ -30,7 +30,7 @@ describe Backoffice::CommentairesController, type: :controller do
subject { dossier.state }
it {is_expected.to eq('reply')}
it {is_expected.to eq('replied')}
end
end
end

View file

@ -17,10 +17,10 @@ describe Users::CommentairesController, type: :controller do
describe 'change dossier state after post a comment' 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
sign_in dossier.user
dossier.reply!
dossier.replied!
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
dossier.reload

View file

@ -22,8 +22,8 @@ describe DossierDecorator do
expect(subject).to eq('Soumis')
end
it 'reply is repondu' do
dossier.reply!
it 'replied is repondu' do
dossier.replied!
expect(subject).to eq('Répondu')
end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
feature 'on backoffice page' do
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
visit backoffice_path
end

View file

@ -191,7 +191,7 @@ describe Dossier do
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('reply')}
it { is_expected.to eq('replied')}
end
context 'when is confirmed the dossier' do
@ -202,9 +202,9 @@ describe Dossier do
end
end
context 'when dossier is at state reply' do
context 'when dossier is at state replied' do
before do
dossier.reply!
dossier.replied!
end
context 'when user is connect' do
@ -232,7 +232,7 @@ describe Dossier do
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('reply')}
it { is_expected.to eq('replied')}
end
context 'when is confirmed the dossier' do
@ -270,7 +270,7 @@ describe Dossier do
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('reply')}
it { is_expected.to eq('replied')}
end
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!(: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!(:dossier4) { create(:dossier, :with_user, :with_procedure, state: 'replied')}
let!(:dossier5) { create(:dossier, :with_user, :with_procedure, state: 'updated')}
let!(:dossier6) { create(:dossier, :with_user, :with_procedure, state: 'confirmed')}
let!(:dossier7) { create(:dossier, :with_user, :with_procedure, state: 'deposited')}

View file

@ -61,9 +61,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
end
end
context 'when dossier have state reply' do
context 'when dossier have state replied' do
before do
dossier.reply!
dossier.replied!
render
end

View file

@ -64,9 +64,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
it { expect(rendered).to have_content('Soumis') }
end
context 'when dossier state is reply' do
context 'when dossier state is replied' do
before do
dossier.reply!
dossier.replied!
render
end