[fix #504] Dossier: received -> en_instruction
This commit is contained in:
parent
72bae2c374
commit
3dda27b281
40 changed files with 143 additions and 108 deletions
|
@ -97,7 +97,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
|||
def receive
|
||||
dossier = Dossier.find(params[:dossier_id])
|
||||
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
current_gestionnaire.follow(dossier)
|
||||
flash.notice = 'Dossier passé en instruction.'
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ module NewGestionnaire
|
|||
end
|
||||
|
||||
def passer_en_instruction
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
current_gestionnaire.follow(dossier)
|
||||
flash.notice = 'Dossier passé en instruction.'
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class Users::RecapitulatifController < UsersController
|
|||
|
||||
def self.route_authorization
|
||||
{
|
||||
states: [:en_construction, :received, :without_continuation, :closed, :refused]
|
||||
states: [:en_construction, :en_instruction, :without_continuation, :closed, :refused]
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ class AutoArchiveProcedureJob < ApplicationJob
|
|||
def perform(*args)
|
||||
Procedure.publiees.where("auto_archive_on <= ?", Date.today).each do |procedure|
|
||||
procedure.dossiers.state_en_construction.each do |dossier|
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
end
|
||||
|
||||
procedure.archive
|
||||
|
|
|
@ -4,7 +4,7 @@ class AutoReceiveDossiersForProcedureJob < ApplicationJob
|
|||
def perform(procedure_id, state)
|
||||
procedure = Procedure.find_by(id: procedure_id)
|
||||
if procedure
|
||||
procedure.dossiers.state_nouveaux.update_all(state: state, received_at: Time.now)
|
||||
procedure.dossiers.state_nouveaux.update_all(state: state, en_instruction_at: Time.now)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ class Dossier < ActiveRecord::Base
|
|||
enum state: {
|
||||
brouillon: 'brouillon',
|
||||
en_construction: 'en_construction',
|
||||
received: 'received',
|
||||
en_instruction: 'en_instruction',
|
||||
closed: 'closed',
|
||||
refused: 'refused',
|
||||
without_continuation: 'without_continuation'
|
||||
|
@ -11,7 +11,7 @@ class Dossier < ActiveRecord::Base
|
|||
BROUILLON = %w(brouillon)
|
||||
NOUVEAUX = %w(en_construction)
|
||||
EN_CONSTRUCTION = %w(en_construction)
|
||||
EN_INSTRUCTION = %w(received)
|
||||
EN_INSTRUCTION = %w(en_instruction)
|
||||
EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION
|
||||
TERMINE = %w(closed refused without_continuation)
|
||||
|
||||
|
@ -164,7 +164,7 @@ class Dossier < ActiveRecord::Base
|
|||
when 'gestionnaire'
|
||||
case action
|
||||
when 'close'
|
||||
if received?
|
||||
if en_instruction?
|
||||
self.attestation = build_attestation
|
||||
save
|
||||
|
||||
|
@ -176,7 +176,7 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
when 'refuse'
|
||||
if received?
|
||||
if en_instruction?
|
||||
refused!
|
||||
|
||||
if motivation
|
||||
|
@ -185,7 +185,7 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
when 'without_continuation'
|
||||
if received?
|
||||
if en_instruction?
|
||||
without_continuation!
|
||||
|
||||
if motivation
|
||||
|
@ -283,7 +283,7 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def read_only?
|
||||
received? || closed? || refused? || without_continuation?
|
||||
en_instruction? || closed? || refused? || without_continuation?
|
||||
end
|
||||
|
||||
def owner? email
|
||||
|
@ -390,8 +390,8 @@ class Dossier < ActiveRecord::Base
|
|||
def update_state_dates
|
||||
if en_construction? && !self.en_construction_at
|
||||
self.en_construction_at = DateTime.now
|
||||
elsif received? && !self.received_at
|
||||
self.received_at = DateTime.now
|
||||
elsif en_instruction? && !self.en_instruction_at
|
||||
self.en_instruction_at = DateTime.now
|
||||
elsif TERMINE.include?(state)
|
||||
self.processed_at = DateTime.now
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class ProcedureOverview
|
|||
@old_dossiers_en_instruction = procedure
|
||||
.dossiers
|
||||
.state_en_instruction
|
||||
.where('received_at < ?', 1.week.ago)
|
||||
.where('en_instruction_at < ?', 1.week.ago)
|
||||
|
||||
@dossiers_en_construction_count = procedure.dossiers.state_en_construction.count
|
||||
@old_dossiers_en_construction = procedure
|
||||
|
|
|
@ -39,6 +39,8 @@ class DossierSerializer < ActiveModel::Serializer
|
|||
case object.state
|
||||
when 'en_construction'
|
||||
'initiated'
|
||||
when 'en_instruction'
|
||||
'received'
|
||||
else
|
||||
object.state
|
||||
end
|
||||
|
@ -52,6 +54,10 @@ class DossierSerializer < ActiveModel::Serializer
|
|||
object.en_construction_at
|
||||
end
|
||||
|
||||
def received_at
|
||||
object.en_instruction_at
|
||||
end
|
||||
|
||||
def accompagnateurs
|
||||
object.followers_gestionnaires.pluck(:email)
|
||||
end
|
||||
|
|
|
@ -26,6 +26,8 @@ class DossierTableExportSerializer < ActiveModel::Serializer
|
|||
case object.state
|
||||
when 'en_construction'
|
||||
'initiated'
|
||||
when 'en_instruction'
|
||||
'received'
|
||||
else
|
||||
object.state
|
||||
end
|
||||
|
@ -35,6 +37,10 @@ class DossierTableExportSerializer < ActiveModel::Serializer
|
|||
object.en_construction_at
|
||||
end
|
||||
|
||||
def received_at
|
||||
object.en_instruction_at
|
||||
end
|
||||
|
||||
def individual_prenom
|
||||
object.individual.try(:prenom)
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
- if !@facade.dossier.read_only? || @facade.dossier.en_construction?
|
||||
= link_to 'Passer en instruction', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block', data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" }
|
||||
|
||||
- elsif @facade.dossier.received?
|
||||
- elsif @facade.dossier.en_instruction?
|
||||
= form_tag(backoffice_dossier_process_dossier_url(@facade.dossier.id), method: :post) do
|
||||
= text_area :dossier, :motivation, class: "motivation-text-area", placeholder: "Motivation (facultative)"
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ fr:
|
|||
state:
|
||||
brouillon: "Brouillon"
|
||||
en_construction: "En construction"
|
||||
received: "En instruction"
|
||||
en_instruction: "En instruction"
|
||||
closed: "Accepté"
|
||||
refused: "Refusé"
|
||||
without_continuation: "Sans suite"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class RenameDossierReceivedAtByEnInstructionAt < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
rename_column :dossiers, :received_at, :en_instruction_at
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20171214112701) do
|
||||
ActiveRecord::Schema.define(version: 20171214155554) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -195,7 +195,7 @@ ActiveRecord::Schema.define(version: 20171214112701) do
|
|||
t.boolean "archived", default: false
|
||||
t.boolean "mandataire_social", default: false
|
||||
t.datetime "en_construction_at"
|
||||
t.datetime "received_at"
|
||||
t.datetime "en_instruction_at"
|
||||
t.datetime "processed_at"
|
||||
t.text "motivation"
|
||||
t.datetime "hidden_at"
|
||||
|
|
|
@ -6,4 +6,8 @@ namespace :'2017_12_04_translate_dossier_state_to_french' do
|
|||
task en_construction: :environment do
|
||||
Dossier.unscoped.where(state: 'initiated').update_all(state: 'en_construction')
|
||||
end
|
||||
|
||||
task en_instruction: :environment do
|
||||
Dossier.unscoped.where(state: 'received').update_all(state: 'en_instruction')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ describe Backoffice::AvisController, type: :controller do
|
|||
let(:claimant){ create(:gestionnaire) }
|
||||
let(:gestionnaire){ create(:gestionnaire) }
|
||||
let!(:dossier) do
|
||||
dossier = create(:dossier, state: 'received')
|
||||
dossier = create(:dossier, state: 'en_instruction')
|
||||
claimant.procedures << [dossier.procedure]
|
||||
dossier
|
||||
end
|
||||
|
@ -40,7 +40,7 @@ describe Backoffice::AvisController, type: :controller do
|
|||
|
||||
describe '#POST update' do
|
||||
let(:gestionnaire){ create(:gestionnaire) }
|
||||
let(:dossier){ create(:dossier, state: 'received') }
|
||||
let(:dossier){ create(:dossier, state: 'en_instruction') }
|
||||
let(:avis){ create(:avis, dossier: dossier, gestionnaire: gestionnaire )}
|
||||
|
||||
subject { post :update, params: { dossier_id: dossier.id, id: avis.id, avis: { answer: "Ok ce dossier est valide." } } }
|
||||
|
|
|
@ -228,7 +228,7 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.state).to eq('received') }
|
||||
it { expect(dossier.state).to eq('en_instruction') }
|
||||
it { is_expected.to redirect_to backoffice_dossier_path(dossier) }
|
||||
it { expect(gestionnaire.follow?(dossier)).to be true }
|
||||
end
|
||||
|
@ -236,7 +236,7 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
describe 'POST #process_dossier' do
|
||||
context "with refuse" do
|
||||
before do
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
|
@ -262,7 +262,7 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
|
||||
context "with without_continuation" do
|
||||
before do
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
|
@ -290,7 +290,7 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
let(:expected_attestation) { nil }
|
||||
|
||||
before do
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
|
||||
expect(NotificationMailer).to receive(:send_notification)
|
||||
|
@ -354,7 +354,7 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
|
||||
describe 'POST #reopen' do
|
||||
before do
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
|
|
|
@ -85,14 +85,14 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.state).to eq('received') }
|
||||
it { expect(dossier.state).to eq('en_instruction') }
|
||||
it { is_expected.to redirect_to dossier_path(procedure, dossier) }
|
||||
it { expect(gestionnaire.follow?(dossier)).to be true }
|
||||
end
|
||||
|
||||
describe '#repasser_en_construction' do
|
||||
before do
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
|
@ -111,7 +111,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
describe '#terminer' do
|
||||
context "with refuser" do
|
||||
before do
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
|
@ -137,7 +137,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
|
||||
context "with classer_sans_suite" do
|
||||
before do
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
|
@ -165,7 +165,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
let(:expected_attestation) { nil }
|
||||
|
||||
before do
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
|
||||
expect(NotificationMailer).to receive(:send_notification)
|
||||
|
|
|
@ -138,13 +138,13 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
|
||||
before do
|
||||
create(:dossier, procedure: procedure, state: "en_construction")
|
||||
create(:dossier, procedure: procedure, state: "received")
|
||||
create(:dossier, procedure: procedure, state: "en_instruction")
|
||||
create(:dossier, procedure: procedure, state: "without_continuation", archived: true)
|
||||
|
||||
gestionnaire.procedures << procedure2
|
||||
create(:dossier, :followed, procedure: procedure2, state: "en_construction")
|
||||
create(:dossier, procedure: procedure2, state: "closed")
|
||||
gestionnaire.followed_dossiers << create(:dossier, procedure: procedure2, state: "received")
|
||||
gestionnaire.followed_dossiers << create(:dossier, procedure: procedure2, state: "en_instruction")
|
||||
|
||||
subject
|
||||
end
|
||||
|
@ -182,7 +182,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'with a new brouillon dossier' do
|
||||
let!(:brouillon_dossier) { create(:dossier, procedure: procedure, state: 'draft') }
|
||||
let!(:brouillon_dossier) { create(:dossier, procedure: procedure, state: 'brouillon') }
|
||||
|
||||
before do
|
||||
get :show, params: { procedure_id: procedure.id }
|
||||
|
@ -196,7 +196,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'with a new dossier without follower' do
|
||||
let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: 'received') }
|
||||
let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: 'en_instruction') }
|
||||
|
||||
before do
|
||||
get :show, params: { procedure_id: procedure.id }
|
||||
|
@ -210,7 +210,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'with a new dossier with a follower' do
|
||||
let!(:new_followed_dossier) { create(:dossier, procedure: procedure, state: 'received') }
|
||||
let!(:new_followed_dossier) { create(:dossier, procedure: procedure, state: 'en_instruction') }
|
||||
|
||||
before do
|
||||
gestionnaire.followed_dossiers << new_followed_dossier
|
||||
|
@ -239,7 +239,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'with an archived dossier' do
|
||||
let!(:archived_dossier) { create(:dossier, procedure: procedure, state: 'received', archived: true) }
|
||||
let!(:archived_dossier) { create(:dossier, procedure: procedure, state: 'en_instruction', archived: true) }
|
||||
|
||||
before do
|
||||
get :show, params: { procedure_id: procedure.id }
|
||||
|
@ -253,10 +253,10 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'statut' do
|
||||
let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago){ create(:dossier, procedure: procedure, state: 'received') } }
|
||||
let!(:new_followed_dossier) { Timecop.freeze(2.day.ago){ create(:dossier, procedure: procedure, state: 'received') } }
|
||||
let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago){ create(:dossier, procedure: procedure, state: 'en_instruction') } }
|
||||
let!(:new_followed_dossier) { Timecop.freeze(2.day.ago){ create(:dossier, procedure: procedure, state: 'en_instruction') } }
|
||||
let!(:termine_dossier) { Timecop.freeze(3.day.ago){ create(:dossier, procedure: procedure, state: 'closed') } }
|
||||
let!(:archived_dossier) { Timecop.freeze(4.day.ago){ create(:dossier, procedure: procedure, state: 'received', archived: true) } }
|
||||
let!(:archived_dossier) { Timecop.freeze(4.day.ago){ create(:dossier, procedure: procedure, state: 'en_instruction', archived: true) } }
|
||||
|
||||
before do
|
||||
gestionnaire.followed_dossiers << new_followed_dossier
|
||||
|
|
|
@ -4,7 +4,7 @@ shared_examples 'carte_controller_spec' do
|
|||
context 'when dossier’s procedure have api carto actived' do
|
||||
context 'when dossier does not have a valid state' do
|
||||
before do
|
||||
dossier.state = 'received'
|
||||
dossier.state = 'en_instruction'
|
||||
dossier.save
|
||||
|
||||
get :show, params: {dossier_id: dossier.id}
|
||||
|
|
|
@ -52,7 +52,7 @@ shared_examples 'description_controller_spec' do
|
|||
describe 'before_action authorized_routes?' do
|
||||
context 'when dossier does not have a valid state' do
|
||||
before do
|
||||
dossier.state = 'received'
|
||||
dossier.state = 'en_instruction'
|
||||
dossier.save
|
||||
|
||||
get :show, params: {dossier_id: dossier.id}
|
||||
|
|
|
@ -39,7 +39,7 @@ describe Users::DossiersController, type: :controller do
|
|||
describe 'before_action authorized_routes?' do
|
||||
context 'when dossier does not have a valid state' do
|
||||
before do
|
||||
dossier.state = 'received'
|
||||
dossier.state = 'en_instruction'
|
||||
dossier.save
|
||||
|
||||
get :show, params: {id: dossier.id}
|
||||
|
|
|
@ -37,8 +37,8 @@ describe DossierDecorator do
|
|||
expect(subject).to eq('Accepté')
|
||||
end
|
||||
|
||||
it 'received is reçu' do
|
||||
dossier.received!
|
||||
it 'en_instruction is reçu' do
|
||||
dossier.en_instruction!
|
||||
expect(subject).to eq('En instruction')
|
||||
end
|
||||
|
||||
|
|
|
@ -80,9 +80,9 @@ FactoryGirl.define do
|
|||
end
|
||||
end
|
||||
|
||||
trait :received do
|
||||
trait :en_instruction do
|
||||
after(:create) do |dossier, _evaluator|
|
||||
dossier.state = 'received'
|
||||
dossier.state = 'en_instruction'
|
||||
dossier.en_construction_at = dossier.created_at + 1.minute
|
||||
dossier.created_at = dossier.created_at + 2.minute
|
||||
dossier.save!
|
||||
|
|
|
@ -12,7 +12,7 @@ FactoryGirl.define do
|
|||
type 'MailRefused'
|
||||
end
|
||||
|
||||
trait :dossier_received do
|
||||
trait :dossier_en_instruction do
|
||||
object "[TPS] Accusé de réception pour votre dossier nº --numero_dossier--"
|
||||
body "Votre administration vous confirme la bonne réception de votre dossier nº --numero_dossier--"
|
||||
type 'MailReceived'
|
||||
|
|
|
@ -13,7 +13,7 @@ feature 'As an Accompagnateur I can navigate and use each functionnality around
|
|||
Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'en_construction')
|
||||
end
|
||||
22.times do
|
||||
Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'received')
|
||||
Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'en_instruction')
|
||||
end
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
visit backoffice_path
|
||||
|
|
|
@ -21,7 +21,7 @@ feature 'The gestionnaire part' do
|
|||
|
||||
click_on 'Passer en instruction'
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('received')
|
||||
expect(dossier.state).to eq('en_instruction')
|
||||
|
||||
within('.accept.motivation') do
|
||||
fill_in('dossier_motivation', with: 'a good reason')
|
||||
|
|
|
@ -4,9 +4,9 @@ feature "procedure filters" do
|
|||
let(:procedure) { create(:procedure, :published, :with_type_de_champ) }
|
||||
let(:gestionnaire) { create(:gestionnaire, procedures: [procedure]) }
|
||||
let!(:type_de_champ) { procedure.types_de_champ.first }
|
||||
let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: "received") }
|
||||
let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: "en_instruction") }
|
||||
let!(:champ) { Champ.find_by(type_de_champ_id: type_de_champ.id, dossier_id: new_unfollow_dossier.id) }
|
||||
let!(:new_unfollow_dossier_2) { create(:dossier, procedure: procedure, state: "received") }
|
||||
let!(:new_unfollow_dossier_2) { create(:dossier, procedure: procedure, state: "en_instruction") }
|
||||
|
||||
before do
|
||||
champ.update_attributes(value: "Mon champ rempli")
|
||||
|
|
|
@ -7,7 +7,7 @@ feature 'on click on tabs button' do
|
|||
|
||||
before do
|
||||
create(:dossier, :with_entreprise, user: user, state: 'en_construction')
|
||||
create(:dossier, :with_entreprise, user: user, state: 'received')
|
||||
create(:dossier, :with_entreprise, user: user, state: 'en_instruction')
|
||||
create(:dossier, :with_entreprise, user: user, state: 'closed')
|
||||
create(:dossier, :with_entreprise, user: user, state: 'refused')
|
||||
create(:dossier, :with_entreprise, user: user, state: 'without_continuation')
|
||||
|
|
|
@ -22,7 +22,7 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do
|
|||
let!(:dossier2) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false)}
|
||||
let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false)}
|
||||
let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false)}
|
||||
let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'received', archived: false)}
|
||||
let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'en_instruction', archived: false)}
|
||||
let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: 'closed', archived: false)}
|
||||
let!(:dossier7) { create(:dossier, procedure: procedure_hier, state: 'refused', archived: false)}
|
||||
let!(:dossier8) { create(:dossier, procedure: procedure_hier, state: 'without_continuation', archived: false)}
|
||||
|
@ -40,14 +40,14 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do
|
|||
end
|
||||
|
||||
it { expect(dossier1.state).to eq 'brouillon' }
|
||||
it { expect(dossier2.state).to eq 'received' }
|
||||
it { expect(dossier3.state).to eq 'received' }
|
||||
it { expect(dossier4.state).to eq 'received' }
|
||||
it { expect(dossier5.state).to eq 'received' }
|
||||
it { expect(dossier2.state).to eq 'en_instruction' }
|
||||
it { expect(dossier3.state).to eq 'en_instruction' }
|
||||
it { expect(dossier4.state).to eq 'en_instruction' }
|
||||
it { expect(dossier5.state).to eq 'en_instruction' }
|
||||
it { expect(dossier6.state).to eq 'closed' }
|
||||
it { expect(dossier7.state).to eq 'refused' }
|
||||
it { expect(dossier8.state).to eq 'without_continuation' }
|
||||
it { expect(dossier9.state).to eq 'received' }
|
||||
it { expect(dossier9.state).to eq 'en_instruction' }
|
||||
|
||||
it { expect(procedure_hier.archivee?).to eq true }
|
||||
it { expect(procedure_aujourdhui.archivee?).to eq true }
|
||||
|
|
|
@ -7,28 +7,28 @@ RSpec.describe AutoReceiveDossiersForProcedureJob, type: :job do
|
|||
before { Timecop.freeze(date) }
|
||||
after { Timecop.return }
|
||||
|
||||
subject { AutoReceiveDossiersForProcedureJob.new.perform(procedure_id, 'received') }
|
||||
subject { AutoReceiveDossiersForProcedureJob.new.perform(procedure_id, 'en_instruction') }
|
||||
|
||||
context "with some dossiers" do
|
||||
let(:nouveau_dossier1) { create(:dossier, :en_construction) }
|
||||
let(:nouveau_dossier2) { create(:dossier, :en_construction, procedure: nouveau_dossier1.procedure) }
|
||||
let(:dossier_recu) { create(:dossier, :received, procedure: nouveau_dossier2.procedure) }
|
||||
let(:dossier_recu) { create(:dossier, :en_instruction, procedure: nouveau_dossier2.procedure) }
|
||||
let(:dossier_brouillon) { create(:dossier, procedure: dossier_recu.procedure) }
|
||||
let(:procedure_id) { dossier_brouillon.procedure_id }
|
||||
|
||||
it do
|
||||
subject
|
||||
expect(nouveau_dossier1.reload.received?).to be true
|
||||
expect(nouveau_dossier1.reload.received_at).to eq(date)
|
||||
expect(nouveau_dossier1.reload.en_instruction?).to be true
|
||||
expect(nouveau_dossier1.reload.en_instruction_at).to eq(date)
|
||||
|
||||
expect(nouveau_dossier2.reload.received?).to be true
|
||||
expect(nouveau_dossier2.reload.received_at).to eq(date)
|
||||
expect(nouveau_dossier2.reload.en_instruction?).to be true
|
||||
expect(nouveau_dossier2.reload.en_instruction_at).to eq(date)
|
||||
|
||||
expect(dossier_recu.reload.received?).to be true
|
||||
expect(dossier_recu.reload.received_at).to eq(date)
|
||||
expect(dossier_recu.reload.en_instruction?).to be true
|
||||
expect(dossier_recu.reload.en_instruction_at).to eq(date)
|
||||
|
||||
expect(dossier_brouillon.reload.brouillon?).to be true
|
||||
expect(dossier_brouillon.reload.received_at).to eq(nil)
|
||||
expect(dossier_brouillon.reload.en_instruction_at).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -200,9 +200,9 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when dossier is at state received' do
|
||||
context 'when dossier is at state en_instruction' do
|
||||
before do
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
end
|
||||
|
||||
context 'when user is connected' do
|
||||
|
@ -211,7 +211,7 @@ describe Dossier do
|
|||
context 'when he posts a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('received') }
|
||||
it { is_expected.to eq('en_instruction') }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -221,7 +221,7 @@ describe Dossier do
|
|||
context 'when he posts a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('received') }
|
||||
it { is_expected.to eq('en_instruction') }
|
||||
end
|
||||
|
||||
context 'when he closes the dossier' do
|
||||
|
@ -394,7 +394,7 @@ describe Dossier do
|
|||
let(:date1) { 1.day.ago }
|
||||
let(:date2) { 1.hour.ago }
|
||||
let(:date3) { 1.minute.ago }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, en_construction_at: date1, received_at: date2, processed_at: date3, motivation: "Motivation") }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, en_construction_at: date1, en_instruction_at: date2, processed_at: date3, motivation: "Motivation") }
|
||||
let!(:follow) { create(:follow, gestionnaire: gestionnaire, dossier: dossier) }
|
||||
|
||||
describe '#export_headers' do
|
||||
|
@ -461,7 +461,7 @@ describe Dossier do
|
|||
"false",
|
||||
"brouillon",
|
||||
dossier.en_construction_at,
|
||||
dossier.received_at,
|
||||
dossier.en_instruction_at,
|
||||
dossier.processed_at,
|
||||
"Motivation",
|
||||
gestionnaire.email,
|
||||
|
@ -702,30 +702,30 @@ describe Dossier do
|
|||
|
||||
it 'should keep first en_construction_at date' do
|
||||
Timecop.return
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
dossier.en_construction!
|
||||
|
||||
expect(dossier.en_construction_at).to eq(beginning_of_day)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is received' do
|
||||
context 'when dossier is en_instruction' do
|
||||
let(:state) { 'en_construction' }
|
||||
|
||||
before do
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.state).to eq('received') }
|
||||
it { expect(dossier.received_at).to eq(beginning_of_day) }
|
||||
it { expect(dossier.state).to eq('en_instruction') }
|
||||
it { expect(dossier.en_instruction_at).to eq(beginning_of_day) }
|
||||
|
||||
it 'should keep first received_at date if dossier is set to en_construction again' do
|
||||
it 'should keep first en_instruction_at date if dossier is set to en_construction again' do
|
||||
Timecop.return
|
||||
dossier.en_construction!
|
||||
dossier.received!
|
||||
dossier.en_instruction!
|
||||
|
||||
expect(dossier.received_at).to eq(beginning_of_day)
|
||||
expect(dossier.en_instruction_at).to eq(beginning_of_day)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -740,19 +740,19 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'when dossier is closed' do
|
||||
let(:state) { 'received' }
|
||||
let(:state) { 'en_instruction' }
|
||||
|
||||
it_behaves_like 'dossier is processed', 'closed'
|
||||
end
|
||||
|
||||
context 'when dossier is refused' do
|
||||
let(:state) { 'received' }
|
||||
let(:state) { 'en_instruction' }
|
||||
|
||||
it_behaves_like 'dossier is processed', 'refused'
|
||||
end
|
||||
|
||||
context 'when dossier is without_continuation' do
|
||||
let(:state) { 'received' }
|
||||
let(:state) { 'en_instruction' }
|
||||
|
||||
it_behaves_like 'dossier is processed', 'without_continuation'
|
||||
end
|
||||
|
@ -762,8 +762,8 @@ describe Dossier do
|
|||
let(:procedure) { create(:procedure) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :brouillon) }
|
||||
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: :en_construction, en_construction_at: DateTime.parse('03/01/2010')) }
|
||||
let!(:dossier3) { create(:dossier, :with_entreprise, procedure: procedure, state: :received, en_construction_at: DateTime.parse('01/01/2010')) }
|
||||
let!(:dossier4) { create(:dossier, :with_entreprise, procedure: procedure, state: :received, archived: true, en_construction_at: DateTime.parse('02/01/2010')) }
|
||||
let!(:dossier3) { create(:dossier, :with_entreprise, procedure: procedure, state: :en_instruction, en_construction_at: DateTime.parse('01/01/2010')) }
|
||||
let!(:dossier4) { create(:dossier, :with_entreprise, procedure: procedure, state: :en_instruction, archived: true, en_construction_at: DateTime.parse('02/01/2010')) }
|
||||
|
||||
subject { procedure.dossiers.downloadable_sorted }
|
||||
|
||||
|
@ -778,8 +778,8 @@ describe Dossier do
|
|||
allow(NotificationMailer).to receive(:send_dossier_received).and_return(double(deliver_later: nil))
|
||||
end
|
||||
|
||||
it "sends an email when the dossier becomes received" do
|
||||
dossier.received!
|
||||
it "sends an email when the dossier becomes en_instruction" do
|
||||
dossier.en_instruction!
|
||||
expect(NotificationMailer).to have_received(:send_dossier_received).with(dossier.id)
|
||||
end
|
||||
|
||||
|
@ -806,7 +806,7 @@ describe Dossier do
|
|||
|
||||
it "does not send an email when the dossier is created with a non brouillon state" do
|
||||
expect { Dossier.create(procedure: procedure, state: "en_construction", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: "received", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: "en_instruction", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: "closed", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: "refused", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: "without_continuation", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
|
@ -822,8 +822,8 @@ describe Dossier do
|
|||
dossier.reload
|
||||
end
|
||||
|
||||
context 'when the dossier is in received state ' do
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, state: :received) }
|
||||
context 'when the dossier is in en_instruction state ' do
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, state: :en_instruction) }
|
||||
|
||||
context 'when the procedure has no attestation' do
|
||||
it { expect(dossier.attestation).to be_nil }
|
||||
|
|
|
@ -268,7 +268,7 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
|
||||
context 'with a followed dossier' do
|
||||
let!(:dossier){create(:dossier, procedure: procedure, state: 'received')}
|
||||
let!(:dossier){create(:dossier, procedure: procedure, state: 'en_instruction')}
|
||||
let!(:follow){ create(:follow, dossier: dossier, gestionnaire: gestionnaire) }
|
||||
|
||||
context 'with 1 notification' do
|
||||
|
@ -291,7 +291,7 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
|
||||
context 'with another dossier' do
|
||||
let!(:dossier2){create(:dossier, procedure: procedure, state: 'received')}
|
||||
let!(:dossier2){create(:dossier, procedure: procedure, state: 'en_instruction')}
|
||||
let!(:follow2){ create(:follow, dossier: dossier2, gestionnaire: gestionnaire) }
|
||||
|
||||
context 'and some notifications' do
|
||||
|
@ -351,7 +351,7 @@ describe Gestionnaire, type: :model do
|
|||
subject{ gestionnaire.can_view_dossier?(dossier.id) }
|
||||
|
||||
context 'when gestionnaire is assigned on dossier' do
|
||||
let!(:dossier){ create(:dossier, procedure: procedure, state: 'received') }
|
||||
let!(:dossier){ create(:dossier, procedure: procedure, state: 'en_instruction') }
|
||||
|
||||
it { expect(subject).to be true }
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ describe ProcedureOverview, type: :model do
|
|||
|
||||
describe 'dossiers_en_instruction_count' do
|
||||
let!(:en_instruction_dossier) do
|
||||
create(:dossier, procedure: procedure, state: :received, created_at: monday)
|
||||
create(:dossier, procedure: procedure, state: :en_instruction, created_at: monday)
|
||||
end
|
||||
|
||||
it { expect(procedure_overview.dossiers_en_instruction_count).to eq(1) }
|
||||
|
@ -20,11 +20,11 @@ describe ProcedureOverview, type: :model do
|
|||
|
||||
describe 'old_dossiers_en_instruction' do
|
||||
let!(:old_dossier_en_instruction) do
|
||||
create(:dossier, procedure: procedure, state: :received, received_at: monday - 1.month)
|
||||
create(:dossier, procedure: procedure, state: :en_instruction, en_instruction_at: monday - 1.month)
|
||||
end
|
||||
|
||||
let!(:dossier_en_instruction) do
|
||||
create(:dossier, procedure: procedure, state: :received, received_at: monday)
|
||||
create(:dossier, procedure: procedure, state: :en_instruction, en_instruction_at: monday)
|
||||
end
|
||||
|
||||
it do
|
||||
|
@ -42,7 +42,7 @@ describe ProcedureOverview, type: :model do
|
|||
|
||||
describe 'created_dossiers_count' do
|
||||
let!(:created_dossier_during_the_week) do
|
||||
create(:dossier, procedure: procedure, created_at: monday, state: :received)
|
||||
create(:dossier, procedure: procedure, created_at: monday, state: :en_instruction)
|
||||
end
|
||||
|
||||
let!(:created_dossier_during_the_week_but_in_brouillon) do
|
||||
|
@ -50,7 +50,7 @@ describe ProcedureOverview, type: :model do
|
|||
end
|
||||
|
||||
let!(:created_dossier_before_the_week) do
|
||||
create(:dossier, procedure: procedure, created_at: (monday - 1.week), state: :received)
|
||||
create(:dossier, procedure: procedure, created_at: (monday - 1.week), state: :en_instruction)
|
||||
end
|
||||
|
||||
it { expect(procedure_overview.created_dossiers_count).to eq(1) }
|
||||
|
|
|
@ -8,5 +8,12 @@ describe DossierSerializer do
|
|||
it { is_expected.to include(initiated_at: dossier.en_construction_at) }
|
||||
it { is_expected.to include(state: 'initiated') }
|
||||
end
|
||||
|
||||
context 'when the dossier is en instruction' do
|
||||
let(:dossier) { create(:dossier, :en_instruction) }
|
||||
|
||||
it { is_expected.to include(received_at: dossier.en_instruction_at) }
|
||||
it { is_expected.to include(state: 'received') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,13 @@ describe DossierTableExportSerializer do
|
|||
it { is_expected.to include(initiated_at: dossier.en_construction_at) }
|
||||
it { is_expected.to include(state: 'initiated') }
|
||||
end
|
||||
|
||||
context 'when the dossier is en instruction' do
|
||||
let(:dossier) { create(:dossier, :en_instruction) }
|
||||
|
||||
it { is_expected.to include(received_at: dossier.en_instruction_at) }
|
||||
it { is_expected.to include(state: 'received') }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#emails_accompagnateurs' do
|
||||
|
|
|
@ -348,8 +348,8 @@ describe DossiersListGestionnaireService do
|
|||
let!(:dossier) { create(:dossier, procedure: procedure, state: 'brouillon') }
|
||||
let!(:dossier2) { create(:dossier, procedure: procedure, state: 'en_construction') } #nouveaux
|
||||
let!(:dossier3) { create(:dossier, procedure: procedure, state: 'en_construction') } #nouveaux
|
||||
let!(:dossier6) { create(:dossier, procedure: procedure, state: 'received') } #a_instruire
|
||||
let!(:dossier7) { create(:dossier, procedure: procedure, state: 'received') } #a_instruire
|
||||
let!(:dossier6) { create(:dossier, procedure: procedure, state: 'en_instruction') } #a_instruire
|
||||
let!(:dossier7) { create(:dossier, procedure: procedure, state: 'en_instruction') } #a_instruire
|
||||
let!(:dossier8) { create(:dossier, procedure: procedure, state: 'closed') } #termine
|
||||
let!(:dossier9) { create(:dossier, procedure: procedure, state: 'refused') } #termine
|
||||
let!(:dossier10) { create(:dossier, procedure: procedure, state: 'without_continuation') } #termine
|
||||
|
|
|
@ -7,7 +7,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
|
|||
let!(:procedure) { create(:procedure, :published, administrateur: administrateur) }
|
||||
|
||||
let!(:decorate_dossier_en_construction) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction').decorate }
|
||||
let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, procedure: procedure, state: 'received').decorate }
|
||||
let!(:decorate_dossier_en_instruction) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_instruction').decorate }
|
||||
let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, procedure: procedure, state: 'closed').decorate }
|
||||
let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, procedure: procedure, state: 'refused').decorate }
|
||||
let!(:decorate_dossier_without_continuation) { create(:dossier, :with_entreprise, procedure: procedure, state: 'without_continuation').decorate }
|
||||
|
@ -19,7 +19,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
|
|||
let(:all_state_dossiers_list) { dossiers_list_facade.service.all_state }
|
||||
|
||||
before do
|
||||
decorate_dossier_received.entreprise.update_column(:raison_sociale, 'plup')
|
||||
decorate_dossier_en_instruction.entreprise.update_column(:raison_sociale, 'plup')
|
||||
decorate_dossier_closed.entreprise.update_column(:raison_sociale, 'plyp')
|
||||
decorate_dossier_refused.entreprise.update_column(:raison_sociale, 'plzp')
|
||||
decorate_dossier_without_continuation.entreprise.update_column(:raison_sociale, 'plnp')
|
||||
|
|
|
@ -40,8 +40,8 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
|
|||
include_examples 'button Passer en instruction is present'
|
||||
end
|
||||
|
||||
context 'when dossier have state received' do
|
||||
let(:state) { 'received' }
|
||||
context 'when dossier have state en_instruction' do
|
||||
let(:state) { 'en_instruction' }
|
||||
|
||||
before do
|
||||
render
|
||||
|
|
|
@ -3,7 +3,7 @@ describe 'new_gestionnaire/dossiers/print.html.haml', type: :view do
|
|||
|
||||
context "with a dossier" do
|
||||
let(:current_gestionnaire) { create(:gestionnaire) }
|
||||
let(:dossier) { create(:dossier, :received) }
|
||||
let(:dossier) { create(:dossier, :en_instruction) }
|
||||
|
||||
before do
|
||||
assign(:dossier, dossier)
|
||||
|
|
|
@ -4,7 +4,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
|
|||
let(:user) { create(:user) }
|
||||
|
||||
let!(:decorate_dossier_en_construction) { create(:dossier, :with_entreprise, user: user, state: 'en_construction').decorate }
|
||||
let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, user: user, state: 'received').decorate }
|
||||
let!(:decorate_dossier_en_instruction) { create(:dossier, :with_entreprise, user: user, state: 'en_instruction').decorate }
|
||||
let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, user: user, state: 'closed').decorate }
|
||||
let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, user: user, state: 'refused').decorate }
|
||||
let!(:decorate_dossier_without_continuation) { create(:dossier, :with_entreprise, user: user, state: 'without_continuation').decorate }
|
||||
|
@ -56,7 +56,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
|
|||
let(:liste) { 'en_instruction' }
|
||||
|
||||
it_behaves_like 'check_tab_content' do
|
||||
let(:decorate_dossier_at_check) { decorate_dossier_received }
|
||||
let(:decorate_dossier_at_check) { decorate_dossier_en_instruction }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue