[Fix #503] Dossier: remove replied

This commit is contained in:
Simon Lehericey 2017-09-21 17:12:21 +02:00
parent 030a11d98c
commit 633b55aca0
32 changed files with 37 additions and 169 deletions

View file

@ -179,7 +179,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
def reopen
create_dossier_facade params[:dossier_id]
@facade.dossier.replied!
@facade.dossier.initiated!
flash.notice = 'Dossier repassé en construction.'
redirect_to_dossier(@facade.dossier)

View file

@ -56,7 +56,7 @@ class Users::CarteController < UsersController
def self.route_authorization
{
states: [:draft, :initiated, :replied, :updated],
states: [:draft, :initiated, :updated],
api_carto: true
}
end

View file

@ -93,7 +93,7 @@ class Users::DescriptionController < UsersController
def self.route_authorization
{
states: [:draft, :initiated, :replied, :updated]
states: [:draft, :initiated, :updated]
}
end

View file

@ -18,7 +18,7 @@ class Users::RecapitulatifController < UsersController
def self.route_authorization
{
states: [:initiated, :replied, :updated, :received, :without_continuation, :closed, :refused]
states: [:initiated, :updated, :received, :without_continuation, :closed, :refused]
}
end

View file

@ -2,7 +2,6 @@ class Dossier < ActiveRecord::Base
enum state: {
draft: 'draft',
initiated: 'initiated',
replied: 'replied', # action utilisateur demandé
updated: 'updated', # etude par l'administration en cours
received: 'received',
closed: 'closed',
@ -12,7 +11,7 @@ class Dossier < ActiveRecord::Base
BROUILLON = %w(draft)
NOUVEAUX = %w(initiated)
EN_CONSTRUCTION = %w(initiated updated replied)
EN_CONSTRUCTION = %w(initiated updated)
EN_INSTRUCTION = %w(received)
EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION
A_INSTRUIRE = %w(received)
@ -161,22 +160,14 @@ class Dossier < ActiveRecord::Base
if draft?
initiated!
end
when 'update'
if replied?
updated!
end
when 'comment'
if replied?
updated!
end
end
when 'gestionnaire'
case action
when 'comment'
if updated?
replied!
initiated!
elsif initiated?
replied!
initiated!
end
when 'follow'
if initiated?

View file

@ -13,7 +13,7 @@
.col-xs-8.title-no-expanse
.carret-right
INFORMATIONS DU DEMANDEUR
- if !@current_gestionnaire && ["draft", "updated", "replied", "initiated"].include?(@facade.dossier.state)
- if !@current_gestionnaire && ["draft", "updated", "initiated"].include?(@facade.dossier.state)
%a#add_siret.action{ href: users_dossier_add_siret_path(dossier_id: @facade.dossier.id) }
.col-lg-4.col-md-4.col-sm-4.col-xs-4.action
Renseigner un SIRET

View file

@ -10,7 +10,6 @@ fr:
state:
draft: "Brouillon"
initiated: "En construction"
replied: "En construction"
updated: "En construction"
received: "En instruction"
closed: "Accepté"

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe Backoffice::CommentairesController, type: :controller do
let(:dossier) { create(:dossier, :replied) }
let(:dossier) { create(:dossier, :initiated) }
let(:dossier_id) { dossier.id }
let(:email_commentaire) { 'test@test.com' }
let(:texte_commentaire) { 'Commentaire de test' }
@ -124,7 +124,7 @@ describe Backoffice::CommentairesController, type: :controller do
subject { dossier.state }
it { is_expected.to eq('replied') }
it { is_expected.to eq('initiated') }
it 'Notification email is send' do
expect(NotificationMailer).to receive(:new_answer).and_return(NotificationMailer)

View file

@ -360,11 +360,11 @@ describe Backoffice::DossiersController, type: :controller do
subject { post :reopen, params: {dossier_id: dossier_id} }
it 'change state to replied' do
it 'change state to initiated' do
subject
dossier.reload
expect(dossier.state).to eq('replied')
expect(dossier.state).to eq('initiated')
end
it { is_expected.to redirect_to backoffice_dossier_path(id: dossier_id) }

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe InvitesController, type: :controller do
let(:dossier) { create(:dossier, :replied) }
let(:dossier) { create(:dossier, :initiated) }
let(:email) { 'plop@octo.com' }
describe '#POST create' do

View file

@ -6,7 +6,7 @@ describe NewGestionnaire::AvisController, type: :controller do
let(:claimant) { create(:gestionnaire) }
let(:gestionnaire) { create(:gestionnaire) }
let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let(:dossier) { create(:dossier, :replied, procedure: procedure) }
let(:dossier) { create(:dossier, :initiated, procedure: procedure) }
let!(:avis_without_answer) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire) }
let!(:avis_with_answer) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire, answer: 'yop') }

View file

@ -5,16 +5,16 @@ describe NewGestionnaire::DossiersController, type: :controller do
let(:gestionnaire) { create(:gestionnaire) }
let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let(:dossier) { create(:dossier, :replied, procedure: procedure) }
let(:dossier) { create(:dossier, :initiated, procedure: procedure) }
before { sign_in(gestionnaire) }
describe '#attestation' do
context 'when a dossier has an attestation' do
let(:fake_pdf) { double(read: 'pdf content') }
let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) }
let!(:dossier) { create(:dossier, :initiated, attestation: Attestation.new, procedure: procedure) }
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) }
let!(:dossier) { create(:dossier, :initiated, attestation: Attestation.new, procedure: procedure) }
it 'returns the attestation pdf' do
allow_any_instance_of(Attestation).to receive(:pdf).and_return(fake_pdf)
@ -148,7 +148,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
end
let(:dossier) do
create(:dossier, :replied, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_datetime])
create(:dossier, :initiated, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_datetime])
end
before do

View file

@ -137,7 +137,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
let(:state) { "initiated" }
before do
create(:dossier, procedure: procedure, state: "replied")
create(:dossier, procedure: procedure, state: "initiated")
create(:dossier, procedure: procedure, state: "received")
create(:dossier, procedure: procedure, state: "without_continuation", archived: true)

View file

@ -1,8 +1,8 @@
require 'spec_helper'
describe NewGestionnaire::RecherchesController, type: :controller do
let(:dossier) { create(:dossier, :replied) }
let(:dossier2) { create(:dossier, :replied, procedure: dossier.procedure) }
let(:dossier) { create(:dossier, :initiated) }
let(:dossier2) { create(:dossier, :initiated, procedure: dossier.procedure) }
let(:gestionnaire) { create(:gestionnaire) }
before { gestionnaire.procedures << dossier2.procedure }
@ -26,7 +26,7 @@ describe NewGestionnaire::RecherchesController, type: :controller do
end
context 'when gestionnaire do not own the dossier' do
let(:dossier3) { create(:dossier, :replied) }
let(:dossier3) { create(:dossier, :initiated) }
let(:query) { dossier3.id }
it { is_expected.to have_http_status(200) }

View file

@ -102,23 +102,5 @@ describe Users::CommentairesController, type: :controller do
end
end
end
describe 'change dossier state after post a comment' do
context 'when user is connected' do
context 'when dossier is at state replied' do
before do
sign_in dossier.user
dossier.replied!
post :create, params: { dossier_id: dossier_id, texte_commentaire: texte_commentaire }
dossier.reload
end
subject { dossier.state }
it { is_expected.to eq('updated') }
end
end
end
end
end

View file

@ -15,13 +15,11 @@ describe Users::Dossiers::CommentairesController, type: :controller do
before do
sign_in invite.user
dossier.replied!
end
it do
subject
is_expected.to redirect_to users_dossiers_invite_path(invite.id)
expect(dossier.state).to eq 'replied'
end
it 'should notify user' do

View file

@ -27,11 +27,6 @@ describe DossierDecorator do
expect(subject).to eq('En construction')
end
it 'replied is repondu' do
dossier.replied!
expect(subject).to eq('En construction')
end
it 'updated is mis à jour' do
dossier.updated!
expect(subject).to eq('En construction')

View file

@ -5,7 +5,7 @@ describe AdminProceduresShowFacades do
let!(:dossier_0) { create(:dossier, procedure: procedure, state: 'draft') }
let!(:dossier_1) { create(:dossier, procedure: procedure, state: 'initiated') }
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'replied') }
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') }
let!(:dossier_6) { create(:dossier, procedure: procedure, archived: true, state: 'initiated') }
let!(:dossier_7) { create(:dossier, procedure: procedure, state: 'updated') }

View file

@ -72,8 +72,8 @@ FactoryGirl.define do
end
end
trait :replied do
state 'replied'
trait :initiated do
state 'initiated'
end
end
end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
feature 'users: flux de commentaires' do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, :with_entreprise, user: user, state: "replied") }
let(:dossier) { create(:dossier, :with_entreprise, user: user, state: "initiated") }
let(:dossier_id) { dossier.id }
let(:champ1) { dossier.champs.first }

View file

@ -2,10 +2,10 @@ require 'spec_helper'
describe 'user access to the list of his dossier' do
let(:user) { create(:user) }
let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'replied')}
let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'replied') }
let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'initiated')}
let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'initiated') }
let!(:dossier2) { create(:dossier, :with_entreprise) }
let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: 'replied') }
let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: 'initiated') }
before do
last_updated_dossier.update_column(:updated_at, "19/07/2052 15:35".to_time)

View file

@ -7,7 +7,6 @@ feature 'on click on tabs button' do
before do
create(:dossier, :with_entreprise, user: user, state: 'initiated')
create(:dossier, :with_entreprise, user: user, state: 'replied')
create(:dossier, :with_entreprise, user: user, state: 'updated')
create(:dossier, :with_entreprise, user: user, state: 'received')
create(:dossier, :with_entreprise, user: user, state: 'closed')
@ -23,7 +22,7 @@ feature 'on click on tabs button' do
context 'when he click on tabs en construction' do
before do
visit users_dossiers_url(liste: :a_traiter)
page.click_on 'En construction 3'
page.click_on 'En construction 2'
end
scenario 'it redirect to users dossier termine' do

View file

@ -182,7 +182,7 @@ describe Dossier do
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('replied') }
it { is_expected.to eq('initiated') }
end
context 'when is follow' do
@ -193,44 +193,6 @@ describe Dossier do
end
end
context 'when dossier is at state replied' do
before do
dossier.replied!
end
context 'when user is connect' do
let(:role) { 'user' }
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('updated') }
end
context 'when is updated dossier informations' do
let(:action) { 'update' }
it { is_expected.to eq('updated') }
end
end
context 'when gestionnaire is connect' do
let(:role) { 'gestionnaire' }
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('replied') }
end
context 'when is follow' do
let(:action) { 'follow' }
it { is_expected.to eq 'replied' }
end
end
end
context 'when dossier is at state updated' do
before do
dossier.updated!
@ -258,7 +220,7 @@ describe Dossier do
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('replied') }
it { is_expected.to eq('initiated') }
end
end
end

View file

@ -309,7 +309,7 @@ describe Procedure do
before do
create :dossier, procedure: procedure, state: :initiated
create :dossier, procedure: procedure, state: :draft
create :dossier, procedure: procedure, state: :replied
create :dossier, procedure: procedure, state: :initiated
end
subject { procedure.total_dossier }

View file

@ -348,8 +348,6 @@ describe DossiersListGestionnaireService do
let!(:dossier) { create(:dossier, procedure: procedure, state: 'draft') }
let!(:dossier2) { create(:dossier, procedure: procedure, state: 'initiated') } #nouveaux
let!(:dossier3) { create(:dossier, procedure: procedure, state: 'initiated') } #nouveaux
let!(:dossier4) { create(:dossier, procedure: procedure, state: 'replied') } #en_attente
let!(:dossier5) { create(:dossier, procedure: procedure, state: 'updated') } #a_traiter
let!(:dossier6) { create(:dossier, procedure: procedure, state: 'received') } #a_instruire
let!(:dossier7) { create(:dossier, procedure: procedure, state: 'received') } #a_instruire
let!(:dossier8) { create(:dossier, procedure: procedure, state: 'closed') } #termine
@ -357,7 +355,6 @@ describe DossiersListGestionnaireService do
let!(:dossier10) { create(:dossier, procedure: procedure, state: 'without_continuation') } #termine
let!(:dossier11) { create(:dossier, procedure: procedure, state: 'closed') } #termine
let!(:dossier12) { create(:dossier, procedure: procedure, state: 'initiated', archived: true) } #a_traiter #archived
let!(:dossier13) { create(:dossier, procedure: procedure, state: 'replied', archived: true) } #en_attente #archived
let!(:dossier14) { create(:dossier, procedure: procedure, state: 'closed', archived: true) } #termine #archived
describe '#termine' do

View file

@ -23,11 +23,6 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_falsey }
end
describe 'replied' do
let(:state) { 'replied' }
it { is_expected.to be_falsey }
end
describe 'updated' do
let(:state) { 'updated' }
it { is_expected.to be_falsey }
@ -53,11 +48,6 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_falsey }
end
describe 'replied' do
let(:state) { 'replied' }
it { is_expected.to be_falsey }
end
describe 'updated' do
let(:state) { 'updated' }
it { is_expected.to be_falsey }
@ -82,11 +72,6 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_truthy }
end
describe 'replied' do
let(:state) { 'replied' }
it { is_expected.to be_truthy }
end
describe 'updated' do
let(:state) { 'updated' }
it { is_expected.to be_truthy }
@ -112,11 +97,6 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_truthy }
end
describe 'replied' do
let(:state) { 'replied' }
it { is_expected.to be_truthy }
end
describe 'updated' do
let(:state) { 'updated' }
it { is_expected.to be_truthy }
@ -141,11 +121,6 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_truthy }
end
describe 'replied' do
let(:state) { 'replied' }
it { is_expected.to be_truthy }
end
describe 'updated' do
let(:state) { 'updated' }
it { is_expected.to be_truthy }

View file

@ -7,7 +7,6 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
let!(:procedure) { create(:procedure, :published, administrateur: administrateur) }
let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated').decorate }
let!(:decorate_dossier_replied) { create(:dossier, :with_entreprise, procedure: procedure, state: 'replied').decorate }
let!(:decorate_dossier_updated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated').decorate }
let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, procedure: procedure, state: 'received').decorate }
let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, procedure: procedure, state: 'closed').decorate }
@ -21,7 +20,6 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
let(:all_state_dossiers_list) { dossiers_list_facade.service.all_state }
before do
decorate_dossier_replied.entreprise.update_column(:raison_sociale, 'plap')
decorate_dossier_updated.entreprise.update_column(:raison_sociale, 'plep')
decorate_dossier_received.entreprise.update_column(:raison_sociale, 'plup')
decorate_dossier_closed.entreprise.update_column(:raison_sociale, 'plyp')
@ -79,14 +77,13 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
it { is_expected.to have_content('Nouveaux dossiers 1 dossier') }
it { is_expected.to have_content('Dossiers suivis 0 dossiers') }
it { is_expected.to have_content('Tous les dossiers 7 dossiers') }
it { is_expected.to have_content('Tous les dossiers 6 dossiers') }
it { is_expected.to have_content('État') }
it { is_expected.to have_content('Libellé procédure') }
it { is_expected.to have_content('Raison sociale') }
it { is_expected.to have_content('Mise à jour le') }
it { is_expected.to have_content('plap') }
it { is_expected.to have_content('plep') }
it { is_expected.to have_content('plup') }
it { is_expected.to have_content('plyp') }

View file

@ -40,18 +40,6 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
include_examples 'button Passer en instruction is present'
end
context 'when dossier have state replied' do
let(:state) { 'replied' }
before do
render
end
it { expect(rendered).to have_content('En construction') }
include_examples 'button Passer en instruction is present'
end
context 'when dossier have state update' do
let(:state) { 'updated' }

View file

@ -20,16 +20,6 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm
it { expect(rendered).to have_content('En construction') }
end
context 'when dossier state is replied' do
let(:state) { 'replied' }
before do
render
end
it { expect(rendered).to have_content('En construction') }
end
context 'when dossier state is updated' do
let(:state) { 'updated' }

View file

@ -1,7 +1,7 @@
describe 'new_gestionnaire/dossiers/show.html.haml', type: :view do
let(:individual) { nil }
let(:entreprise) { nil }
let(:dossier) { create(:dossier, :replied, entreprise: entreprise, individual: individual) }
let(:dossier) { create(:dossier, :initiated, entreprise: entreprise, individual: individual) }
before do
assign(:dossier, dossier)

View file

@ -4,7 +4,6 @@ describe 'users/dossiers/index.html.haml', type: :view do
let(:user) { create(:user) }
let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, user: user, state: 'initiated').decorate }
let!(:decorate_dossier_replied) { create(:dossier, :with_entreprise, user: user, state: 'replied').decorate }
let!(:decorate_dossier_updated) { create(:dossier, :with_entreprise, user: user, state: 'updated').decorate }
let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, user: user, state: 'received').decorate }
let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, user: user, state: 'closed').decorate }
@ -41,7 +40,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
end
describe 'on tab en construction' do
let(:total_dossiers) { 3 }
let(:total_dossiers) { 2 }
let(:active_class) { '.active .text-danger' }
let(:dossiers_to_display) { user.dossiers.state_en_construction }
let(:liste) { 'a_traiter' }
@ -50,10 +49,6 @@ describe 'users/dossiers/index.html.haml', type: :view do
let(:decorate_dossier_at_check) { decorate_dossier_initiated }
end
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_replied }
end
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_updated }
end

View file

@ -20,7 +20,7 @@ RSpec.describe AutoArchiveProcedureWorker, type: :worker do
context "when procedures have auto_archive_on set on yesterday or today" do
let!(:dossier1) { create(:dossier, procedure: procedure_hier, state: 'draft', archived: false)}
let!(:dossier2) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)}
let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'replied', archived: false)}
let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)}
let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'updated', archived: false)}
let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'received', archived: false)}
let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: 'closed', archived: false)}