Delete tab Nouveau A traiter and En cours d'étude for User and replace this only one call En construction

This commit is contained in:
Xavier J 2016-10-19 17:25:24 +02:00
parent fd9eaa5a4d
commit a7166d306f
9 changed files with 110 additions and 87 deletions

View file

@ -53,6 +53,10 @@ class DossiersListFacades
(@liste == 'a_traiter' ? 'active' : '')
end
def en_construction_class
(@liste == 'a_traiter' ? 'active' : '')
end
def en_attente_class
(@liste == 'en_attente' ? 'active' : '')
end
@ -98,13 +102,15 @@ class DossiersListFacades
end
def a_traiter_total
return service.waiting_for_gestionnaire.count if gestionnaire?
service.waiting_for_user.count if user?
service.waiting_for_gestionnaire.count
end
def en_construction_total
service.en_construction.count
end
def en_attente_total
return service.waiting_for_user.count if gestionnaire?
service.waiting_for_gestionnaire.count if user?
service.waiting_for_user.count
end
def valides_total
@ -147,6 +153,10 @@ class DossiersListFacades
base_url 'a_traiter'
end
def en_construction_url
base_url 'a_traiter'
end
def en_attente_url
base_url 'en_attente'
end

View file

@ -47,7 +47,7 @@ class Dossier < ActiveRecord::Base
NOUVEAUX = %w(initiated)
WAITING_FOR_GESTIONNAIRE = %w(updated)
WAITING_FOR_USER = %w(replied validated)
WAITING_FOR_USER_WITHOUT_VALIDATED = %w(replied)
EN_CONSTRUCTION = %w(initiated updated replied)
VALIDES = %w(validated)
DEPOSES = %w(submitted)
EN_INSTRUCTION = %w(submitted received)
@ -185,8 +185,8 @@ class Dossier < ActiveRecord::Base
WAITING_FOR_USER.include?(state)
end
def waiting_for_user_without_validated?
WAITING_FOR_USER_WITHOUT_VALIDATED.include?(state)
def en_construction?
EN_CONSTRUCTION.include?(state)
end
def deposes?
@ -225,8 +225,8 @@ class Dossier < ActiveRecord::Base
where(state: WAITING_FOR_USER, archived: false).order("updated_at #{order}")
end
def self.waiting_for_user_without_validated order = 'ASC'
where(state: WAITING_FOR_USER_WITHOUT_VALIDATED, archived: false).order("updated_at #{order}")
def self.en_construction order = 'ASC'
where(state: EN_CONSTRUCTION, archived: false).order("updated_at #{order}")
end
def self.valides order = 'ASC'

View file

@ -121,7 +121,7 @@ class DossiersListGestionnaireService
def joins_filter
filter_preference_list.inject([]) do |acc, preference|
acc.push(preference.table.to_sym) unless preference.table.blank?
acc.push(preference.table.to_sym) unless preference.table.blank? || preference.filter.blank?
acc
end
end

View file

@ -6,9 +6,7 @@ class DossiersListUserService
def dossiers_to_display
{'brouillon' => brouillon,
'nouveaux' => nouveaux,
'a_traiter' => waiting_for_user,
'en_attente' => waiting_for_gestionnaire,
'a_traiter' => en_construction,
'valides' => valides,
'en_instruction' => en_instruction,
'termine' => termine,
@ -16,23 +14,15 @@ class DossiersListUserService
end
def self.dossiers_liste_libelle
['brouillon', 'nouveaux', 'a_traiter', 'en_attente', 'valides', 'en_instruction', 'termine', 'invite']
['brouillon', 'a_traiter', 'valides', 'en_instruction', 'termine', 'invite']
end
def brouillon
@brouillon ||= @current_devise_profil.dossiers.brouillon
end
def nouveaux
@nouveaux ||= @current_devise_profil.dossiers.nouveaux
end
def waiting_for_gestionnaire
@waiting_for_gestionnaire ||= @current_devise_profil.dossiers.waiting_for_gestionnaire
end
def waiting_for_user
@waiting_for_user ||= @current_devise_profil.dossiers.waiting_for_user_without_validated
def en_construction
@en_construction ||= @current_devise_profil.dossiers.en_construction
end
def invite

View file

@ -8,26 +8,12 @@
.badge.progress-bar-default
= @dossiers_list_facade.brouillon_total
%li{ class: @dossiers_list_facade.nouveaux_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'nouveaux')}", 'data-toggle' => :tooltip, title: 'Les nouveaux dossiers qui n\'ont pas encore été vus par votre accompagnateur.'}
%h5.text-info
= "Nouveaux"
.badge.progress-bar-info
= @dossiers_list_facade.nouveaux_total
%li{ class: @dossiers_list_facade.a_traiter_class }
%li{ class: @dossiers_list_facade.en_construction_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'a_traiter')}", 'data-toggle' => :tooltip, title: 'Les dossiers qui requièrent une action de votre part.'}
%h5.text-danger
= "Action requise"
= "En construction"
.badge.progress-bar-danger
= @dossiers_list_facade.a_traiter_total
%li{ class: @dossiers_list_facade.en_attente_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'en_attente')}", 'data-toggle' => :tooltip, title: 'Les dossiers en cours de relecture par votre accompagnateur.'}
%h5.text-default
="Etude en cours"
.badge.progress-bar-default
= @dossiers_list_facade.en_attente_total
= @dossiers_list_facade.en_construction_total
%li{ class: @dossiers_list_facade.valides_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'valides')}", 'data-toggle' => :tooltip, title: 'Les dossiers relus par votre accompagnateur pouvant être déposés pour examen.'}

View file

@ -418,14 +418,40 @@ describe Users::DossiersController, type: :controller do
end
end
describe 'GET #en_attente' do
describe 'GET #valides' do
context 'when user is connected' do
before do
sign_in user
end
it 'returns http success' do
get :index, liste: :en_attente
get :index, liste: :valides
expect(response).to have_http_status(200)
end
end
end
describe 'GET #en_instruction' do
context 'when user is connected' do
before do
sign_in user
end
it 'returns http success' do
get :index, liste: :en_instruction
expect(response).to have_http_status(200)
end
end
end
describe 'GET #brouillon' do
context 'when user is connected' do
before do
sign_in user
end
it 'returns http success' do
get :index, liste: :brouillon
expect(response).to have_http_status(200)
end
end

View file

@ -22,21 +22,10 @@ feature 'on click on tabs button' do
end
context 'when user is logged in' do
context 'when he click on tabs nouveaux' do
before do
visit users_dossiers_url(liste: :nouveaux)
page.click_on 'Nouveaux 1'
end
scenario 'it redirect to users dossier termine' do
expect(page).to have_css('#users_index')
end
end
context 'when he click on tabs a traite' do
context 'when he click on tabs en construction' do
before do
visit users_dossiers_url(liste: :a_traiter)
page.click_on 'Action requise 1'
page.click_on 'En construction 3'
end
scenario 'it redirect to users dossier termine' do
@ -44,17 +33,6 @@ feature 'on click on tabs button' do
end
end
context 'when he click on tabs en attente' do
before do
visit users_dossiers_url(liste: :en_attente)
page.click_on 'Etude en cours 1'
end
scenario 'it redirect to users dossier en attente' do
expect(page).to have_css('#users_index')
end
end
context 'when he click on tabs a deposes' do
before do
visit users_dossiers_url(liste: :valides)

View file

@ -125,6 +125,43 @@ describe DossiersListGestionnaireService do
end
end
describe '#join_filter' do
subject { DossiersListGestionnaireService.new(gestionnaire, liste, nil).joins_filter }
it { is_expected.to eq []}
context 'when a filter is fielded' do
before do
gestionnaire.preference_list_dossiers
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
.update_column :filter, 'plop'
end
it { is_expected.to eq [:entreprise] }
end
context 'when a filter is empty' do
before do
gestionnaire.preference_list_dossiers
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
.update_column :filter, ''
end
it { is_expected.to eq [] }
end
context 'when a filter is nil' do
before do
gestionnaire.preference_list_dossiers
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
.update_column :filter, nil
end
it { is_expected.to eq [] }
end
end
describe '#where_filter' do
before do
gestionnaire.preference_list_dossiers
@ -181,6 +218,16 @@ describe DossiersListGestionnaireService do
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE '%MCDONALD''S FRANCE%'" }
end
context "when filter is empty " do
before do
gestionnaire.preference_list_dossiers
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
.update_column :filter, ""
end
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%'" }
end
context 'when preference list contain a champ' do
before do
create :preference_list_dossier,

View file

@ -46,33 +46,19 @@ describe 'users/dossiers/index.html.haml', type: :view do
end
end
describe 'on tab nouveaux' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-info' }
let(:dossiers_to_display) { user.dossiers.nouveaux }
let(:liste) { 'nouveaux' }
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(:liste) { 'a_traiter' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_initiated }
end
end
describe 'on tab action requise' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-danger' }
let(:dossiers_to_display) { user.dossiers.waiting_for_user_without_validated }
let(:liste) { 'a_traiter' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_replied }
end
end
describe 'on tab etude en cours' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-default' }
let(:dossiers_to_display) { user.dossiers.waiting_for_gestionnaire }
let(:liste) { 'en_attente' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_updated }