Rename some Dossier scopes

This commit is contained in:
gregoirenovel 2017-05-26 18:59:21 +02:00
parent 51dd6df1c0
commit ab1c19c09b
8 changed files with 23 additions and 24 deletions

View file

@ -16,13 +16,13 @@ class Users::DossiersController < UsersController
@dossiers_filtered = case @liste
when 'brouillon'
@user_dossiers.brouillon.order_by_updated_at
@user_dossiers.state_brouillon.order_by_updated_at
when 'a_traiter'
@user_dossiers.en_construction.order_by_updated_at
@user_dossiers.state_en_construction.order_by_updated_at
when 'en_instruction'
@user_dossiers.en_instruction.order_by_updated_at
@user_dossiers.state_en_instruction.order_by_updated_at
when 'termine'
@user_dossiers.termine.order_by_updated_at
@user_dossiers.state_termine.order_by_updated_at
when 'invite'
current_user.invites
else

View file

@ -41,18 +41,18 @@ class Dossier < ActiveRecord::Base
belongs_to :procedure
belongs_to :user
scope :brouillon, -> { where(state: BROUILLON) }
scope :not_brouillon, -> { where.not(state: BROUILLON) }
scope :en_construction, -> { where(state: EN_CONSTRUCTION) }
scope :en_instruction, -> { where(state: EN_INSTRUCTION) }
scope :termine, -> { where(state: TERMINE) }
scope :state_brouillon, -> { where(state: BROUILLON) }
scope :state_not_brouillon, -> { where.not(state: BROUILLON) }
scope :state_en_construction, -> { where(state: EN_CONSTRUCTION) }
scope :state_en_instruction, -> { where(state: EN_INSTRUCTION) }
scope :state_termine, -> { where(state: TERMINE) }
scope :archived, -> { where(archived: true) }
scope :not_archived, -> { where(archived: false) }
scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) }
scope :downloadable, -> { not_brouillon.order_by_updated_at("ASC") }
scope :downloadable, -> { state_not_brouillon.order_by_updated_at("ASC") }
accepts_nested_attributes_for :individual
@ -173,7 +173,7 @@ class Dossier < ActiveRecord::Base
end
def self.all_state order = 'ASC'
not_brouillon.not_archived.order_by_updated_at(order)
state_not_brouillon.not_archived.order_by_updated_at(order)
end
def brouillon?

View file

@ -45,7 +45,7 @@ class DossiersListGestionnaireService
end
def termine
@termine ||= filter_dossiers.termine.not_archived
@termine ||= filter_dossiers.state_termine.not_archived
end
def filter_dossiers

View file

@ -15,25 +15,25 @@
.procedure-list-element#brouillon{ class: ('active' if @liste == 'brouillon') }
Brouillons
.badge.progress-bar-default
= @user_dossiers.brouillon.count
= @user_dossiers.state_brouillon.count
%a{ :href => "#{url_for users_dossiers_path(liste: 'a_traiter')}", 'data-toggle' => :tooltip, title: 'Les dossiers qui requièrent une action de votre part.' }
.procedure-list-element#a_traiter{ class: ('active' if @liste == 'a_traiter') }
En construction
.badge.progress-bar-danger
= @user_dossiers.en_construction.count
= @user_dossiers.state_en_construction.count
%a{ :href => "#{url_for users_dossiers_path(liste: 'en_instruction')}", 'data-toggle' => :tooltip, title: 'Les dossiers en cours d\'examen par l\'administration compétante.' }
.procedure-list-element#en_instruction{ class: ('active' if @liste == 'en_instruction') }
En instruction
.badge.progress-bar-default
= @user_dossiers.en_instruction.count
= @user_dossiers.state_en_instruction.count
%a{ :href => "#{url_for users_dossiers_path(liste: 'termine')}", 'data-toggle' => :tooltip, title: 'Les dossiers cloturés qui peuvent être "Accepté", "Refusé" ou "Sans suite".' }
.procedure-list-element#termine{ class: ('active' if @liste == 'termine') }
Terminé
.badge.progress-bar-success
= @user_dossiers.termine.count
= @user_dossiers.state_termine.count
%a{ :href => "#{url_for users_dossiers_path(liste: 'invite')}" }
.procedure-list-element#invite{ class: ('active' if @liste == 'invite') }

View file

@ -5,7 +5,7 @@ class AutoArchiveProcedureWorker
procedures_to_archive = Procedure.not_archived.where("auto_archive_on <= ?", Date.today)
procedures_to_archive.each do |p|
p.dossiers.en_construction.update_all(state: :received)
p.dossiers.state_en_construction.update_all(state: :received)
end
procedures_to_archive.update_all(archived: true, auto_archive_on: nil)

View file

@ -455,8 +455,8 @@ describe Dossier do
it { expect(subject.size).to eq(1) }
end
describe '#en_instruction' do
subject { gestionnaire.dossiers.en_instruction }
describe '#state_en_instruction' do
subject { gestionnaire.dossiers.state_en_instruction }
it { expect(subject.size).to eq(2) }
it { expect(subject).to include(dossier6, dossier7) }

View file

@ -364,7 +364,7 @@ describe DossiersListGestionnaireService do
let!(:dossier14) { create(:dossier, procedure: procedure, state: 'closed', archived: true) } #termine #archived
describe '#termine' do
subject { DossiersListGestionnaireService.new(gestionnaire, liste, procedure).termine }
subject { DossiersListGestionnaireService.new(gestionnaire, liste, procedure).state_termine }
it { expect(subject.size).to eq(4) }
it { expect(subject).to include(dossier8, dossier9, dossier10, dossier11) }

View file

@ -43,7 +43,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
describe 'on tab en construction' do
let(:total_dossiers) { 3 }
let(:active_class) { '.active .text-danger' }
let(:dossiers_to_display) { user.dossiers.en_construction }
let(:dossiers_to_display) { user.dossiers.state_en_construction }
let(:liste) { 'a_traiter' }
it_behaves_like 'check_tab_content' do
@ -59,11 +59,10 @@ describe 'users/dossiers/index.html.haml', type: :view do
end
end
describe 'on tab etude en examen' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-default' }
let(:dossiers_to_display) { user.dossiers.en_instruction }
let(:dossiers_to_display) { user.dossiers.state_en_instruction }
let(:liste) { 'en_instruction' }
it_behaves_like 'check_tab_content' do
@ -74,7 +73,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
describe 'on tab etude termine' do
let(:total_dossiers) { 3 }
let(:active_class) { '.active .text-success' }
let(:dossiers_to_display) { user.dossiers.termine }
let(:dossiers_to_display) { user.dossiers.state_termine }
let(:liste) { 'termine' }
it_behaves_like 'check_tab_content' do