[fix #504] Dossier: initiated -> en_construction

The change must not impact the api
This commit is contained in:
LeSim 2017-12-14 15:51:45 +01:00
parent 461dd9e843
commit 56545933a9
72 changed files with 261 additions and 187 deletions

View file

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

View file

@ -69,7 +69,7 @@ module NewGestionnaire
end
def repasser_en_construction
dossier.initiated!
dossier.en_construction!
flash.notice = 'Dossier repassé en construction.'
redirect_to dossier_path(procedure, dossier)

View file

@ -13,8 +13,8 @@ class StatsController < ApplicationController
@procedures_cumulative = cumulative_hash(procedures, :published_at)
@procedures_in_the_last_4_months = last_four_months_hash(procedures, :published_at)
@dossiers_cumulative = cumulative_hash(dossiers, :initiated_at)
@dossiers_in_the_last_4_months = last_four_months_hash(dossiers, :initiated_at)
@dossiers_cumulative = cumulative_hash(dossiers, :en_construction_at)
@dossiers_in_the_last_4_months = last_four_months_hash(dossiers, :en_construction_at)
@procedures_count_per_administrateur = procedures_count_per_administrateur(procedures)
@ -96,7 +96,7 @@ class StatsController < ApplicationController
processed_dossiers = dossiers
.where(:processed_at => min_date..max_date)
.pluck(:procedure_id, :initiated_at, :processed_at)
.pluck(:procedure_id, :en_construction_at, :processed_at)
# Group dossiers by month
processed_dossiers_by_month = processed_dossiers
@ -137,7 +137,7 @@ class StatsController < ApplicationController
processed_dossiers = dossiers
.where(:processed_at => min_date..max_date)
.pluck(:procedure_id, :created_at, :initiated_at, :processed_at)
.pluck(:procedure_id, :created_at, :en_construction_at, :processed_at)
# Group dossiers by month
processed_dossiers_by_month = processed_dossiers

View file

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

View file

@ -14,7 +14,7 @@ class Users::DescriptionController < UsersController
@headers = @champs.select { |c| c.type_champ == 'header_section' }
unless @dossier.can_be_initiated?
unless @dossier.can_be_en_construction?
flash[:alert] = t('errors.messages.procedure_archived')
end
@ -27,7 +27,7 @@ class Users::DescriptionController < UsersController
dossier = current_user_dossier
procedure = dossier.procedure
return head :forbidden unless dossier.can_be_initiated?
return head :forbidden unless dossier.can_be_en_construction?
ChampsService.save_champs(dossier.champs, params) if params[:champs]
@ -51,8 +51,8 @@ class Users::DescriptionController < UsersController
redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon)
else
if dossier.draft?
dossier.initiated!
NotificationMailer.send_notification(dossier, procedure.initiated_mail_template).deliver_now!
dossier.en_construction!
end
flash.notice = 'Félicitations, votre demande a bien été enregistrée.'
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: dossier.id)
@ -93,7 +93,7 @@ class Users::DescriptionController < UsersController
def self.route_authorization
{
states: [:draft, :initiated]
states: [:draft, :en_construction]
}
end

View file

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

View file

@ -1,7 +1,7 @@
class Dossier < ActiveRecord::Base
enum state: {
draft: 'draft',
initiated: 'initiated',
en_construction: 'en_construction',
received: 'received',
closed: 'closed',
refused: 'refused',
@ -9,8 +9,8 @@ class Dossier < ActiveRecord::Base
}
BROUILLON = %w(draft)
NOUVEAUX = %w(initiated)
EN_CONSTRUCTION = %w(initiated)
NOUVEAUX = %w(en_construction)
EN_CONSTRUCTION = %w(en_construction)
EN_INSTRUCTION = %w(received)
EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION
TERMINE = %w(closed refused without_continuation)
@ -58,7 +58,7 @@ class Dossier < ActiveRecord::Base
scope :nouveaux, -> { not_archived.state_nouveaux }
scope :en_instruction, -> { not_archived.state_en_instruction }
scope :termine, -> { not_archived.state_termine }
scope :downloadable_sorted, -> { state_not_brouillon.includes(:entreprise, :etablissement, :champs, :champs_private).order(initiated_at: 'asc') }
scope :downloadable_sorted, -> { state_not_brouillon.includes(:entreprise, :etablissement, :champs, :champs_private).order(en_construction_at: 'asc') }
scope :en_cours, -> { not_archived.state_en_construction_ou_instruction }
scope :without_followers, -> { left_outer_joins(:follows).where(follows: { id: nil }) }
scope :with_unread_notifications, -> { where(notifications: { already_read: false }) }
@ -158,7 +158,7 @@ class Dossier < ActiveRecord::Base
case action
when 'initiate'
if draft?
initiated!
en_construction!
end
end
when 'gestionnaire'
@ -294,7 +294,7 @@ class Dossier < ActiveRecord::Base
(invites_user.pluck :email).include? email
end
def can_be_initiated?
def can_be_en_construction?
!(procedure.archivee? && draft?)
end
@ -309,7 +309,7 @@ class Dossier < ActiveRecord::Base
else
parts = [
"Dossier déposé le ",
initiated_at.localtime.strftime("%d/%m/%Y"),
en_construction_at.localtime.strftime("%d/%m/%Y"),
" sur la procédure ",
procedure.libelle,
" gérée par l'organisme ",
@ -388,8 +388,8 @@ class Dossier < ActiveRecord::Base
end
def update_state_dates
if initiated? && !self.initiated_at
self.initiated_at = DateTime.now
if en_construction? && !self.en_construction_at
self.en_construction_at = DateTime.now
elsif received? && !self.received_at
self.received_at = DateTime.now
elsif TERMINE.include?(state)

View file

@ -20,7 +20,7 @@ class ProcedureOverview
@old_dossiers_en_construction = procedure
.dossiers
.state_en_construction
.where('initiated_at < ?', 1.week.ago)
.where('en_construction_at < ?', 1.week.ago)
@created_dossiers_count = procedure
.dossiers

View file

@ -35,10 +35,23 @@ class DossierSerializer < ActiveModel::Serializer
object.user.try(:email)
end
def state
case object.state
when 'en_construction'
'initiated'
else
object.state
end
end
def simplified_state
object.decorate.display_state
end
def initiated_at
object.en_construction_at
end
def accompagnateurs
object.followers_gestionnaires.pluck(:email)
end

View file

@ -22,6 +22,19 @@ class DossierTableExportSerializer < ActiveModel::Serializer
object.user.try(:email)
end
def state
case object.state
when 'en_construction'
'initiated'
else
object.state
end
end
def initiated_at
object.en_construction_at
end
def individual_prenom
object.individual.try(:prenom)
end

View file

@ -2,4 +2,8 @@ class DossiersSerializer < ActiveModel::Serializer
attributes :id,
:updated_at,
:initiated_at
def initiated_at
object.en_construction_at
end
end

View file

@ -13,7 +13,7 @@
.col-xs-8.title-no-expanse
.carret-right
INFORMATIONS DU DEMANDEUR
- if !@current_gestionnaire && ["draft", "initiated"].include?(@facade.dossier.state)
- if !@current_gestionnaire && ["draft", "en_construction"].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

@ -4,7 +4,7 @@
- if current_gestionnaire && current_gestionnaire.assigned_on_procedure?(@facade.dossier.procedure_id)
#action-block
- if !@facade.dossier.read_only? || @facade.dossier.initiated?
- 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?

View file

@ -36,7 +36,7 @@
%div{ style: 'text-align: right;' }
%h6 Tous les champs portant un * sont obligatoires.
- if !@dossier.can_be_initiated?
- if !@dossier.can_be_en_construction?
.alert.alert-danger
= t('errors.messages.procedure_archived')
- elsif !@dossier.draft?

View file

@ -9,7 +9,7 @@ fr:
date_previsionnelle: "La date de début prévisionnelle"
state:
draft: "Brouillon"
initiated: "En construction"
en_construction: "En construction"
received: "En instruction"
closed: "Accepté"
refused: "Refusé"

View file

@ -0,0 +1,5 @@
class RenameDossierInitiatedByEnConstruction < ActiveRecord::Migration[5.0]
def change
rename_column :dossiers, :initiated_at, :en_construction_at
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171205151128) do
ActiveRecord::Schema.define(version: 20171214112701) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -194,7 +194,7 @@ ActiveRecord::Schema.define(version: 20171205151128) do
t.text "json_latlngs"
t.boolean "archived", default: false
t.boolean "mandataire_social", default: false
t.datetime "initiated_at"
t.datetime "en_construction_at"
t.datetime "received_at"
t.datetime "processed_at"
t.text "motivation"

View file

@ -0,0 +1,5 @@
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
end

View file

@ -25,7 +25,7 @@ describe API::V1::DossiersController do
context 'when procedure is found and belongs to admin' do
let(:procedure_id) { procedure.id }
let(:date_creation) { Time.utc(2008, 9, 1, 10, 5, 0) }
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :initiated, procedure: procedure) } }
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :en_construction, procedure: procedure) } }
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
it 'return REST code 200', :show_in_doc do
@ -61,8 +61,8 @@ describe API::V1::DossiersController do
context 'when there are multiple pages' do
let(:retour) { get :index, params: {token: admin.api_token, procedure_id: procedure_id, page: 2} }
let!(:dossier1) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
let!(:dossier1) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
before do
allow(Dossier).to receive(:per_page).and_return(1)

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe Backoffice::CommentairesController, type: :controller do
let(:dossier) { create(:dossier, :initiated) }
let(:dossier) { create(:dossier, :en_construction) }
let(:dossier_id) { dossier.id }
let(:email_commentaire) { 'test@test.com' }
let(:texte_commentaire) { 'Commentaire de test' }
@ -89,10 +89,10 @@ describe Backoffice::CommentairesController, type: :controller do
describe 'change dossier state after post a comment' do
context 'gestionnaire is connected' do
context 'when dossier is at state initiated' do
context 'when dossier is at state en_construction' do
before do
sign_in gestionnaire
dossier.initiated!
dossier.en_construction!
post :create, params: {dossier_id: dossier_id, texte_commentaire: texte_commentaire}
dossier.reload

View file

@ -4,7 +4,7 @@ describe Backoffice::Dossiers::ProcedureController, type: :controller do
let(:gestionnaire) { create :gestionnaire }
let(:procedure) { create :procedure, :published }
let(:archived) { false }
let(:dossier) { create :dossier, procedure: procedure, archived: archived, state: 'initiated'}
let(:dossier) { create :dossier, procedure: procedure, archived: archived, state: 'en_construction'}
before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure

View file

@ -7,8 +7,8 @@ describe Backoffice::DossiersController, type: :controller do
let(:procedure) { create :procedure, :published }
let(:procedure2) { create :procedure, :published }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :initiated) }
let(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure2, state: :initiated) }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :en_construction) }
let(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure2, state: :en_construction) }
let(:dossier_archived) { create(:dossier, :with_entreprise, archived: true) }
let(:dossier_id) { dossier.id }
@ -222,7 +222,7 @@ describe Backoffice::DossiersController, type: :controller do
describe 'POST #receive' do
before do
dossier.initiated!
dossier.en_construction!
sign_in gestionnaire
post :receive, params: { dossier_id: dossier_id }
dossier.reload
@ -360,11 +360,11 @@ describe Backoffice::DossiersController, type: :controller do
subject { post :reopen, params: {dossier_id: dossier_id} }
it 'change state to initiated' do
it 'change state to en_construction' do
subject
dossier.reload
expect(dossier.state).to eq('initiated')
expect(dossier.state).to eq('en_construction')
end
it { is_expected.to redirect_to backoffice_dossier_path(id: dossier_id) }

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe Backoffice::PrivateFormulairesController, type: :controller do
let(:gestionnaire) { create :gestionnaire }
let(:dossier) { create :dossier, state: :initiated }
let(:dossier) { create :dossier, state: :en_construction }
let(:dossier_champs_first) { 'plop' }
before do

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe InvitesController, type: :controller do
let(:dossier) { create(:dossier, :initiated) }
let(:dossier) { create(:dossier, :en_construction) }
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, :initiated, procedure: procedure) }
let(:dossier) { create(:dossier, :en_construction, 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, :initiated, procedure: procedure) }
let(:dossier) { create(:dossier, :en_construction, 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, :initiated, attestation: Attestation.new, procedure: procedure) }
let!(:dossier) { create(:dossier, :en_construction, attestation: Attestation.new, procedure: procedure) }
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let!(:dossier) { create(:dossier, :initiated, attestation: Attestation.new, procedure: procedure) }
let!(:dossier) { create(:dossier, :en_construction, attestation: Attestation.new, procedure: procedure) }
it 'returns the attestation pdf' do
allow_any_instance_of(Attestation).to receive(:pdf).and_return(fake_pdf)
@ -79,7 +79,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
describe '#passer_en_instruction' do
before do
dossier.initiated!
dossier.en_construction!
sign_in gestionnaire
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id }
dossier.reload
@ -98,11 +98,11 @@ describe NewGestionnaire::DossiersController, type: :controller do
subject { post :repasser_en_construction, params: { procedure_id: procedure.id, dossier_id: dossier.id} }
it 'change state to initiated' do
it 'change state to en_construction' do
subject
dossier.reload
expect(dossier.state).to eq('initiated')
expect(dossier.state).to eq('en_construction')
end
it { is_expected.to redirect_to dossier_path(procedure, dossier) }
@ -344,7 +344,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
end
let(:dossier) do
create(:dossier, :initiated, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_datetime])
create(:dossier, :en_construction, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_datetime])
end
before do

View file

@ -134,15 +134,15 @@ describe NewGestionnaire::ProceduresController, type: :controller do
context "with not draft state on multiple procedures" do
let(:procedure2) { create(:procedure, :published) }
let(:state) { "initiated" }
let(:state) { "en_construction" }
before do
create(:dossier, procedure: procedure, state: "initiated")
create(:dossier, procedure: procedure, state: "en_construction")
create(:dossier, procedure: procedure, state: "received")
create(:dossier, procedure: procedure, state: "without_continuation", archived: true)
gestionnaire.procedures << procedure2
create(:dossier, :followed, procedure: procedure2, state: "initiated")
create(:dossier, :followed, procedure: procedure2, state: "en_construction")
create(:dossier, procedure: procedure2, state: "closed")
gestionnaire.followed_dossiers << create(:dossier, procedure: procedure2, state: "received")

View file

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

View file

@ -141,21 +141,21 @@ describe StatsController, type: :controller do
procedure_1 = FactoryGirl.create(:procedure)
procedure_2 = FactoryGirl.create(:procedure)
dossier_p1_a = FactoryGirl.create(:dossier,
:procedure => procedure_1,
:initiated_at => 2.months.ago.beginning_of_month,
:processed_at => 2.months.ago.beginning_of_month + 3.days)
:procedure => procedure_1,
:en_construction_at => 2.months.ago.beginning_of_month,
:processed_at => 2.months.ago.beginning_of_month + 3.days)
dossier_p1_b = FactoryGirl.create(:dossier,
:procedure => procedure_1,
:initiated_at => 2.months.ago.beginning_of_month,
:processed_at => 2.months.ago.beginning_of_month + 1.days)
:procedure => procedure_1,
:en_construction_at => 2.months.ago.beginning_of_month,
:processed_at => 2.months.ago.beginning_of_month + 1.days)
dossier_p1_c = FactoryGirl.create(:dossier,
:procedure => procedure_1,
:initiated_at => 1.months.ago.beginning_of_month,
:processed_at => 1.months.ago.beginning_of_month + 5.days)
:procedure => procedure_1,
:en_construction_at => 1.months.ago.beginning_of_month,
:processed_at => 1.months.ago.beginning_of_month + 5.days)
dossier_p2_a = FactoryGirl.create(:dossier,
:procedure => procedure_2,
:initiated_at => 2.month.ago.beginning_of_month,
:processed_at => 2.month.ago.beginning_of_month + 4.days)
:procedure => procedure_2,
:en_construction_at => 2.month.ago.beginning_of_month,
:processed_at => 2.month.ago.beginning_of_month + 4.days)
# Write directly in the DB to avoid the before_validation hook
Dossier.update_all(state: "closed")
@ -191,22 +191,22 @@ describe StatsController, type: :controller do
dossier_p1_a = FactoryGirl.create(:dossier,
:procedure => procedure_1,
:created_at => 2.months.ago.beginning_of_month,
:initiated_at => 2.months.ago.beginning_of_month + 30.minutes,
:en_construction_at => 2.months.ago.beginning_of_month + 30.minutes,
:processed_at => 2.months.ago.beginning_of_month + 1.day)
dossier_p1_b = FactoryGirl.create(:dossier,
:procedure => procedure_1,
:created_at => 2.months.ago.beginning_of_month,
:initiated_at => 2.months.ago.beginning_of_month + 10.minutes,
:en_construction_at => 2.months.ago.beginning_of_month + 10.minutes,
:processed_at => 2.months.ago.beginning_of_month + 1.day)
dossier_p1_c = FactoryGirl.create(:dossier,
:procedure => procedure_1,
:created_at => 1.months.ago.beginning_of_month,
:initiated_at => 1.months.ago.beginning_of_month + 50.minutes,
:en_construction_at => 1.months.ago.beginning_of_month + 50.minutes,
:processed_at => 1.months.ago.beginning_of_month + 1.day)
dossier_p2_a = FactoryGirl.create(:dossier,
:procedure => procedure_2,
:created_at => 2.month.ago.beginning_of_month,
:initiated_at => 2.month.ago.beginning_of_month + 80.minutes,
:en_construction_at => 2.month.ago.beginning_of_month + 80.minutes,
:processed_at => 2.month.ago.beginning_of_month + 1.day)
# Write directly in the DB to avoid the before_validation hook

View file

@ -67,7 +67,7 @@ shared_examples 'carte_controller_spec' do
end
context 'En train de modifier la localisation' do
let(:dossier) { create(:dossier, state: 'initiated') }
let(:dossier) { create(:dossier, state: 'en_construction') }
before do
post :save, params: {dossier_id: dossier.id, json_latlngs: ''}
end

View file

@ -125,7 +125,7 @@ shared_examples 'description_controller_spec' do
end
it 'etat du dossier est soumis' do
expect(dossier.state).to eq('initiated')
expect(dossier.state).to eq('en_construction')
end
context 'when user whould like save just a draft' do
@ -143,7 +143,7 @@ shared_examples 'description_controller_spec' do
context 'En train de manipuler un dossier non brouillon' do
before do
dossier.initiated!
dossier.en_construction!
post :update, params: {dossier_id: dossier_id}
dossier.reload
end

View file

@ -6,7 +6,7 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: '
let(:owner_user) { create(:user) }
let(:invite_by_user) { create :user, email: 'invite@plop.com' }
let(:archived_at) { nil }
let(:state) { 'initiated' }
let(:state) { 'en_construction' }
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: true, published_at: Time.now, archived_at: archived_at) }
let(:dossier) { create(:dossier, procedure: procedure, user: owner_user, state: state) }

View file

@ -435,7 +435,7 @@ describe Users::DossiersController, type: :controller do
describe 'DELETE #destroy' do
let(:user) { create(:user) }
let!(:dossier_draft) { create :dossier, state: "draft", user: user }
let!(:dossier_not_draft) { create :dossier, state: "initiated", user: user }
let!(:dossier_not_draft) { create :dossier, state: "en_construction", user: user }
subject { delete :destroy, params: {id: dossier.id} }

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe Users::RecapitulatifController, type: :controller do
let(:dossier) { create(:dossier, state: 'initiated') }
let(:dossier) { create(:dossier, state: 'en_construction') }
let(:bad_dossier_id) { Dossier.count + 100000 }
before do
@ -43,10 +43,10 @@ describe Users::RecapitulatifController, type: :controller do
it 'dossier change his state for closed' do
dossier.reload
expect(dossier.state).to eq('initiated')
expect(dossier.state).to eq('en_construction')
end
it 'a message informe user what his dossier is initiated' do
it 'a message informe user what his dossier is en_construction' do
expect(flash[:notice]).to include('Dossier soumis avec succès.')
end
end

View file

@ -27,8 +27,8 @@ describe DossierDecorator do
expect(subject).to eq('Brouillon')
end
it 'initiated is initiate' do
dossier.initiated!
it 'en_construction is En construction' do
dossier.en_construction!
expect(subject).to eq('En construction')
end
@ -74,7 +74,7 @@ describe DossierDecorator do
context "when the dossier is not in brouillon state" do
before do
dossier.state = 'initiated'
dossier.state = 'en_construction'
dossier.save
end

View file

@ -4,9 +4,9 @@ describe AdminProceduresShowFacades do
let!(:procedure) { create(:procedure) }
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: 'initiated') }
let!(:dossier_6) { create(:dossier, procedure: procedure, archived: true, state: 'initiated') }
let!(:dossier_1) { create(:dossier, procedure: procedure, state: 'en_construction') }
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'en_construction') }
let!(:dossier_6) { create(:dossier, procedure: procedure, archived: true, state: 'en_construction') }
subject { AdminProceduresShowFacades.new procedure }
@ -33,7 +33,7 @@ describe AdminProceduresShowFacades do
it { expect(subject.size).to eq(1) }
it { expect(subject.first.state).to eq('initiated') }
it { expect(subject.first.state).to eq('en_construction') }
it { expect(subject.first.total).to eq(1) }
end

View file

@ -72,10 +72,10 @@ FactoryGirl.define do
end
end
trait :initiated do
trait :en_construction do
after(:create) do |dossier, _evaluator|
dossier.state = 'initiated'
dossier.initiated_at = dossier.created_at + 1.minute
dossier.state = 'en_construction'
dossier.en_construction_at = dossier.created_at + 1.minute
dossier.save!
end
end
@ -83,7 +83,7 @@ FactoryGirl.define do
trait :received do
after(:create) do |dossier, _evaluator|
dossier.state = 'received'
dossier.initiated_at = dossier.created_at + 1.minute
dossier.en_construction_at = dossier.created_at + 1.minute
dossier.created_at = dossier.created_at + 2.minute
dossier.save!
end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
feature 'add commentaire on backoffice' do
let(:procedure) { create(:procedure, :published) }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
let(:dossier_id) { dossier.id }
let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'toto@toto.com') }
let(:email_commentaire) { 'test@test.com' }

View file

@ -3,7 +3,7 @@ require 'spec_helper'
feature 'backoffice: flux de commentaires' do
let(:procedure) { create(:procedure, :published) }
let(:gestionnaire) { create(:gestionnaire) }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
let(:dossier_id) { dossier.id }
let(:champ1) { create(:champ, dossier: dossier, type_de_champ: create(:type_de_champ_public, libelle: "subtitle1")) }

View file

@ -10,7 +10,7 @@ feature 'As an Accompagnateur I can navigate and use each functionnality around
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
30.times do
Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'initiated')
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')

View file

@ -6,7 +6,7 @@ feature 'usage of pref list dossier lateral panel', js: true do
let(:procedure) { create(:procedure, :published, administrateur: administrateur) }
before do
create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated')
create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction')
create :assign_to, procedure: procedure, gestionnaire: gestionnaire
login_as gestionnaire, scope: :gestionnaire

View file

@ -6,7 +6,7 @@ feature 'usage of pref list dossier lateral panel by procedure', js: true do
let(:procedure) { create(:procedure, :published, :with_type_de_champ, administrateur: administrateur) }
before do
create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated')
create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction')
create :assign_to, procedure: procedure, gestionnaire: gestionnaire
login_as gestionnaire, scope: :gestionnaire

View file

@ -6,8 +6,8 @@ feature 'on backoffice page', js: true do
let(:procedure) { create(:procedure, :published, administrateur: administrateur) }
let(:procedure_individual) { create :procedure, :published, libelle: 'procedure individual', administrateur: administrateur, for_individual: true }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'initiated' }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'en_construction' }
before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
@ -34,7 +34,7 @@ feature 'on backoffice page', js: true do
end
context "and goes to the page of a dossier he hasn't access to" do
let!(:unauthorized_dossier) { create(:dossier, :with_entreprise, state: 'initiated') }
let!(:unauthorized_dossier) { create(:dossier, :with_entreprise, state: 'en_construction') }
before do
visit backoffice_dossier_path(unauthorized_dossier)

View file

@ -39,8 +39,8 @@ feature 'search file on gestionnaire backoffice' do
end
context 'when terms input does return result' do
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'en_construction') }
let(:terms) { dossier.entreprise.raison_sociale }

View file

@ -5,7 +5,7 @@ feature 'The gestionnaire part' do
let!(:gestionnaire) { create(:gestionnaire, password: password) }
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let!(:dossier) { create(:dossier, state: :initiated, procedure: procedure) }
let!(:dossier) { create(:dossier, state: :en_construction, procedure: procedure) }
scenario 'A gestionnaire can accept a dossier' do
log_in(gestionnaire.email, password)

View file

@ -3,7 +3,7 @@ require 'spec_helper'
feature 'As a User I want to edit a dossier I own' do
let(:user) { create(:user) }
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_type_de_champ, :with_two_type_de_piece_justificative, :with_dossier_link) }
let!(:dossier) { create(:dossier, :with_entreprise, :for_individual, :with_dossier_link, procedure: procedure_for_individual, user: user, autorisation_donnees: true, state: 'initiated') }
let!(:dossier) { create(:dossier, :with_entreprise, :for_individual, :with_dossier_link, procedure: procedure_for_individual, user: user, autorisation_donnees: true, state: 'en_construction') }
before "Create dossier and visit root path" do
login_as user, scope: :user

View file

@ -14,7 +14,7 @@ feature 'As a User I want to sort and paginate dossiers', js: true do
page.find_by_id('etape_suivante').trigger('click')
page.find_by_id('suivant').trigger('click')
50.times do
Dossier.create(procedure_id: procedure_for_individual.id, user_id: user.id, state: "initiated")
Dossier.create(procedure_id: procedure_for_individual.id, user_id: user.id, state: "en_construction")
end
visit root_path
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: "initiated") }
let(:dossier) { create(:dossier, :with_entreprise, user: user, state: "en_construction") }
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: 'initiated')}
let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'initiated') }
let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'en_construction')}
let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'en_construction') }
let!(:dossier2) { create(:dossier, :with_entreprise) }
let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: 'initiated') }
let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: 'en_construction') }
before do
last_updated_dossier.update_column(:updated_at, "19/07/2052 15:35".to_time)

View file

@ -3,10 +3,10 @@ require 'spec_helper'
feature 'on click on tabs button' do
let(:user) { create :user }
let(:dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'initiated') }
let(:dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'en_construction') }
before do
create(:dossier, :with_entreprise, user: user, state: 'initiated')
create(:dossier, :with_entreprise, user: user, state: 'en_construction')
create(:dossier, :with_entreprise, user: user, state: 'received')
create(:dossier, :with_entreprise, user: user, state: 'closed')
create(:dossier, :with_entreprise, user: user, state: 'refused')

View file

@ -19,14 +19,14 @@ RSpec.describe AutoArchiveProcedureJob, type: :job 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: 'initiated', archived: false)}
let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)}
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!(: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)}
let!(:dossier9) { create(:dossier, procedure: procedure_aujourdhui, state: 'initiated', archived: false)}
let!(:dossier9) { create(:dossier, procedure: procedure_aujourdhui, state: 'en_construction', archived: false)}
before do
subject

View file

@ -10,8 +10,8 @@ RSpec.describe AutoReceiveDossiersForProcedureJob, type: :job do
subject { AutoReceiveDossiersForProcedureJob.new.perform(procedure_id, 'received') }
context "with some dossiers" do
let(:nouveau_dossier1) { create(:dossier, :initiated) }
let(:nouveau_dossier2) { create(:dossier, :initiated, procedure: nouveau_dossier1.procedure) }
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_draft) { create(:dossier, procedure: dossier_recu.procedure) }
let(:procedure_id) { dossier_draft.procedure_id }

View file

@ -112,7 +112,7 @@ describe Dossier do
it 'does not create default champs' do
expect(subject).not_to receive(:build_default_champs)
subject.update_attributes(state: 'initiated')
subject.update_attributes(state: 'en_construction')
end
end
end
@ -157,14 +157,14 @@ describe Dossier do
context 'when he initiate a dossier' do
let(:action) { 'initiate' }
it { is_expected.to eq('initiated') }
it { is_expected.to eq('en_construction') }
end
end
end
context 'when dossier is at state initiated' do
context 'when dossier is at state en_construction' do
before do
dossier.initiated!
dossier.en_construction!
end
context 'when user is connect' do
@ -173,13 +173,13 @@ describe Dossier do
context 'when is update dossier informations' do
let(:action) { 'update' }
it { is_expected.to eq('initiated') }
it { is_expected.to eq('en_construction') }
end
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('initiated') }
it { is_expected.to eq('en_construction') }
end
end
@ -189,13 +189,13 @@ describe Dossier do
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('initiated') }
it { is_expected.to eq('en_construction') }
end
context 'when is follow' do
let(:action) { 'follow' }
it { is_expected.to eq 'initiated' }
it { is_expected.to eq 'en_construction' }
end
end
end
@ -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, initiated_at: date1, received_at: date2, processed_at: date3, motivation: "Motivation") }
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, en_construction_at: date1, received_at: date2, processed_at: date3, motivation: "Motivation") }
let!(:follow) { create(:follow, gestionnaire: gestionnaire, dossier: dossier) }
describe '#export_headers' do
@ -460,7 +460,7 @@ describe Dossier do
dossier.user.email,
"false",
"draft",
dossier.initiated_at,
dossier.en_construction_at,
dossier.received_at,
dossier.processed_at,
"Motivation",
@ -615,15 +615,15 @@ describe Dossier do
describe "#text_summary" do
let(:procedure) { create(:procedure, libelle: "Procédure", organisation: "Organisme") }
context 'when the dossier has been initiated' do
let(:dossier) { create :dossier, procedure: procedure, state: 'initiated', initiated_at: "31/12/2010".to_date }
context 'when the dossier has been en_construction' do
let(:dossier) { create :dossier, procedure: procedure, state: 'en_construction', en_construction_at: "31/12/2010".to_date }
subject { dossier.text_summary }
it { is_expected.to eq("Dossier déposé le 31/12/2010 sur la procédure Procédure gérée par l'organisme Organisme") }
end
context 'when the dossier has not been initiated' do
context 'when the dossier has not been en_construction' do
let(:dossier) { create :dossier, procedure: procedure, state: 'draft' }
subject { dossier.text_summary }
@ -634,7 +634,7 @@ describe Dossier do
describe '#avis_for' do
let!(:procedure) { create(:procedure, :published) }
let!(:dossier) { create(:dossier, procedure: procedure, state: :initiated) }
let!(:dossier) { create(:dossier, procedure: procedure, state: :en_construction) }
let!(:gestionnaire) { create(:gestionnaire, procedures: [procedure]) }
let!(:expert_1) { create(:gestionnaire) }
@ -691,26 +691,26 @@ describe Dossier do
Timecop.freeze(beginning_of_day)
end
context 'when dossier is initiated' do
context 'when dossier is en_construction' do
before do
dossier.initiated!
dossier.en_construction!
dossier.reload
end
it { expect(dossier.state).to eq('initiated') }
it { expect(dossier.initiated_at).to eq(beginning_of_day) }
it { expect(dossier.state).to eq('en_construction') }
it { expect(dossier.en_construction_at).to eq(beginning_of_day) }
it 'should keep first initiated_at date' do
it 'should keep first en_construction_at date' do
Timecop.return
dossier.received!
dossier.initiated!
dossier.en_construction!
expect(dossier.initiated_at).to eq(beginning_of_day)
expect(dossier.en_construction_at).to eq(beginning_of_day)
end
end
context 'when dossier is received' do
let(:state) { 'initiated' }
let(:state) { 'en_construction' }
before do
dossier.received!
@ -720,9 +720,9 @@ describe Dossier do
it { expect(dossier.state).to eq('received') }
it { expect(dossier.received_at).to eq(beginning_of_day) }
it 'should keep first received_at date if dossier is set to initiated again' do
it 'should keep first received_at date if dossier is set to en_construction again' do
Timecop.return
dossier.initiated!
dossier.en_construction!
dossier.received!
expect(dossier.received_at).to eq(beginning_of_day)
@ -761,9 +761,9 @@ describe Dossier do
describe '.downloadable_sorted' do
let(:procedure) { create(:procedure) }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :draft) }
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: :initiated, initiated_at: DateTime.parse('03/01/2010')) }
let!(:dossier3) { create(:dossier, :with_entreprise, procedure: procedure, state: :received, initiated_at: DateTime.parse('01/01/2010')) }
let!(:dossier4) { create(:dossier, :with_entreprise, procedure: procedure, state: :received, archived: true, initiated_at: DateTime.parse('02/01/2010')) }
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')) }
subject { procedure.dossiers.downloadable_sorted }
@ -772,7 +772,7 @@ describe Dossier do
describe "#send_dossier_received" do
let(:procedure) { create(:procedure) }
let(:dossier) { create(:dossier, procedure: procedure, state: :initiated) }
let(:dossier) { create(:dossier, procedure: procedure, state: :en_construction) }
before do
allow(NotificationMailer).to receive(:send_dossier_received).and_return(double(deliver_later: nil))
@ -805,7 +805,7 @@ describe Dossier do
end
it "does not send an email when the dossier is created with a non draft state" do
expect { Dossier.create(procedure: procedure, state: "initiated", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
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: "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)

View file

@ -169,7 +169,7 @@ describe Gestionnaire, type: :model do
end
context 'when gestionnaire follow a dossier with a notification into the procedure past in params' do
let(:dossier) { create(:dossier, procedure: procedure, state: 'initiated') }
let(:dossier) { create(:dossier, procedure: procedure, state: 'en_construction') }
before do
create :follow, gestionnaire: gestionnaire, dossier: dossier
@ -405,7 +405,7 @@ describe Gestionnaire, type: :model do
end
describe '#notifications_for_dossier' do
let!(:dossier) { create(:dossier, :followed, state: 'initiated') }
let!(:dossier) { create(:dossier, :followed, state: 'en_construction') }
let(:gestionnaire) { dossier.follows.first.gestionnaire }
subject { gestionnaire.notifications_for_dossier(dossier) }
@ -454,12 +454,12 @@ describe Gestionnaire, type: :model do
end
describe '#notification_for_procedure' do
let!(:dossier) { create(:dossier, :followed, state: 'initiated') }
let!(:dossier) { create(:dossier, :followed, state: 'en_construction') }
let(:gestionnaire) { dossier.follows.first.gestionnaire }
let(:procedure) { dossier.procedure }
let!(:gestionnaire_2) { create(:gestionnaire, procedures: [procedure]) }
let!(:dossier_on_procedure_2) { create(:dossier, :followed, state: 'initiated') }
let!(:dossier_on_procedure_2) { create(:dossier, :followed, state: 'en_construction') }
let!(:gestionnaire_on_procedure_2) { dossier_on_procedure_2.follows.first.gestionnaire }
before do
@ -535,7 +535,7 @@ describe Gestionnaire, type: :model do
end
describe '#notifications_per_procedure' do
let!(:dossier) { create(:dossier, :followed, state: 'initiated') }
let!(:dossier) { create(:dossier, :followed, state: 'en_construction') }
let(:gestionnaire) { dossier.follows.first.gestionnaire }
let(:procedure) { dossier.procedure }
@ -549,7 +549,7 @@ describe Gestionnaire, type: :model do
end
describe '#mark_tab_as_seen' do
let!(:dossier) { create(:dossier, :followed, state: 'initiated') }
let!(:dossier) { create(:dossier, :followed, state: 'en_construction') }
let(:gestionnaire) { dossier.follows.first.gestionnaire }
let(:freeze_date) { DateTime.parse('12/12/2012') }

View file

@ -34,7 +34,7 @@ describe ProcedureOverview, type: :model do
describe 'dossiers_en_construction_count' do
let!(:dossier_en_construction) do
create(:dossier, procedure: procedure, state: :initiated, created_at: monday)
create(:dossier, procedure: procedure, state: :en_construction, created_at: monday)
end
it { expect(procedure_overview.dossiers_en_construction_count).to eq(1) }

View file

@ -307,9 +307,9 @@ describe Procedure do
let(:procedure) { create :procedure }
before do
create :dossier, procedure: procedure, state: :initiated
create :dossier, procedure: procedure, state: :en_construction
create :dossier, procedure: procedure, state: :draft
create :dossier, procedure: procedure, state: :initiated
create :dossier, procedure: procedure, state: :en_construction
end
subject { procedure.total_dossier }
@ -331,7 +331,7 @@ describe Procedure do
end
context 'when there are some dossiers' do
let!(:dossier){ create(:dossier, procedure: procedure, state: 'initiated') }
let!(:dossier){ create(:dossier, procedure: procedure, state: 'en_construction') }
let!(:dossier2){ create(:dossier, procedure: procedure, state: 'closed') }
it { expect(subject[:data].size).to eq(2) }

View file

@ -23,10 +23,10 @@ describe Search do
let(:procedure_2) { create(:procedure, :published, administrateur: administrateur_2) }
let!(:dossier_0) { create(:dossier, state: 'draft', procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) }
let!(:dossier_1) { create(:dossier, state: 'initiated', procedure: procedure_1, user: create(:user, email: 'contact@test.com')) }
let!(:dossier_2) { create(:dossier, state: 'initiated', procedure: procedure_1, user: create(:user, email: 'plop@gmail.com')) }
let!(:dossier_3) { create(:dossier, state: 'initiated', procedure: procedure_2, user: create(:user, email: 'peace@clap.fr')) }
let!(:dossier_archived) { create(:dossier, state: 'initiated', procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) }
let!(:dossier_1) { create(:dossier, state: 'en_construction', procedure: procedure_1, user: create(:user, email: 'contact@test.com')) }
let!(:dossier_2) { create(:dossier, state: 'en_construction', procedure: procedure_1, user: create(:user, email: 'plop@gmail.com')) }
let!(:dossier_3) { create(:dossier, state: 'en_construction', procedure: procedure_2, user: create(:user, email: 'peace@clap.fr')) }
let!(:dossier_archived) { create(:dossier, state: 'en_construction', procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) }
let!(:etablissement_1) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'OCTO Academy', dossier: dossier_1), dossier: dossier_1, siret: '41636169600051') }
let!(:etablissement_2) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'Plop octo', dossier: dossier_2), dossier: dossier_2, siret: '41816602300012') }

View file

@ -0,0 +1,12 @@
describe DossierSerializer do
describe '#attributes' do
subject { DossierSerializer.new(dossier).serializable_hash }
context 'when the dossier is en_construction' do
let(:dossier) { create(:dossier, :en_construction) }
it { is_expected.to include(initiated_at: dossier.en_construction_at) }
it { is_expected.to include(state: 'initiated') }
end
end
end

View file

@ -1,6 +1,17 @@
require 'spec_helper'
describe DossierTableExportSerializer do
describe '#attributes' do
subject { DossierTableExportSerializer.new(dossier).serializable_hash }
context 'when the dossier is en_construction' do
let(:dossier) { create(:dossier, :en_construction) }
it { is_expected.to include(initiated_at: dossier.en_construction_at) }
it { is_expected.to include(state: 'initiated') }
end
end
describe '#emails_accompagnateurs' do
let(:gestionnaire){ create(:gestionnaire) }
let(:gestionnaire2) { create :gestionnaire}

View file

@ -0,0 +1,11 @@
describe DossiersSerializer do
describe '#attributes' do
subject { DossiersSerializer.new(dossier).serializable_hash }
context 'when the dossier is en_construction' do
let(:dossier) { create(:dossier, :en_construction) }
it { is_expected.to include(initiated_at: dossier.en_construction_at) }
end
end
end

View file

@ -346,15 +346,15 @@ describe DossiersListGestionnaireService do
describe 'state filter methods' do
let!(:procedure) { create :procedure }
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!(: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!(: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
let!(:dossier11) { create(:dossier, procedure: procedure, state: 'closed') } #termine
let!(:dossier12) { create(:dossier, procedure: procedure, state: 'initiated', archived: true) } #a_traiter #archived
let!(:dossier12) { create(:dossier, procedure: procedure, state: 'en_construction', archived: true) } #a_traiter #archived
let!(:dossier14) { create(:dossier, procedure: procedure, state: 'closed', archived: true) } #termine #archived
describe '#termine' do

View file

@ -18,8 +18,8 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_truthy }
end
describe 'initiated' do
let(:state) { 'initiated' }
describe 'en_construction' do
let(:state) { 'en_construction' }
it { is_expected.to be_falsey }
end
@ -38,8 +38,8 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_falsey }
end
describe 'initiated' do
let(:state) { 'initiated' }
describe 'en_construction' do
let(:state) { 'en_construction' }
it { is_expected.to be_falsey }
end
@ -57,8 +57,8 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_truthy }
end
describe 'initiated' do
let(:state) { 'initiated' }
describe 'en_construction' do
let(:state) { 'en_construction' }
it { is_expected.to be_truthy }
end
@ -77,8 +77,8 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_truthy }
end
describe 'initiated' do
let(:state) { 'initiated' }
describe 'en_construction' do
let(:state) { 'en_construction' }
it { is_expected.to be_truthy }
end
@ -96,8 +96,8 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_falsey }
end
describe 'initiated' do
let(:state) { 'initiated' }
describe 'en_construction' do
let(:state) { 'en_construction' }
it { is_expected.to be_truthy }
end

View file

@ -45,7 +45,7 @@ describe 'admin/previsualisations/show.html.haml', type: :view do
context 'si la page précédente est recapitularif' do
before do
dossier.initiated!
dossier.en_construction!
dossier.reload
render
end

View file

@ -6,7 +6,7 @@ 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_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_closed) { create(:dossier, :with_entreprise, procedure: procedure, state: 'closed').decorate }
let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, procedure: procedure, state: 'refused').decorate }

View file

@ -28,8 +28,8 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
it { expect(rendered).to have_link('Passer en instruction') }
end
context 'when dossier have state initiated' do
let(:state) { 'initiated' }
context 'when dossier have state en_construction' do
let(:state) { 'en_construction' }
before do
render

View file

@ -11,8 +11,8 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm
end
context 'buttons to change dossier state' do
context 'when dossier state is initiated' do
let(:state) { 'initiated' }
context 'when dossier state is en_construction' do
let(:state) { 'en_construction' }
before do
render
end

View file

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

View file

@ -14,7 +14,7 @@ describe 'new_gestionnaire/procedures/_download_dossiers.html.haml', type: :view
end
context "when procedure has at least 1 dossier en construction" do
let!(:dossier) { create(:dossier, :initiated, procedure: procedure) }
let!(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
it { is_expected.to include("Télécharger tous les dossiers") }
end
end

View file

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

View file

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

View file

@ -3,12 +3,12 @@ require 'spec_helper'
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_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_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 }
let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'initiated').decorate }
let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'en_construction').decorate }
before do
create :invite, dossier: decorate_dossier_invite, user: user
@ -45,7 +45,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
let(:liste) { 'a_traiter' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_initiated }
let(:decorate_dossier_at_check) { decorate_dossier_en_construction }
end
end

View file

@ -59,8 +59,8 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
end
end
context 'when dossier state is initiated' do
let(:state) { 'initiated' }
context 'when dossier state is en_construction' do
let(:state) { 'en_construction' }
before do
render
end