diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 7e1d6f016..5d9cb834e 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -1,6 +1,10 @@ class Users::DossiersController < UsersController before_action :authenticate_user! + def index + redirect_to users_dossiers_a_traiter_path + end + def show @dossier = current_user_dossier params[:id] @@ -81,7 +85,7 @@ class Users::DossiersController < UsersController end def a_traiter - @dossiers_a_traiter = current_user.dossiers.waiting_for_user + @dossiers_a_traiter = current_user.dossiers.waiting_for_user 'DESC' @dossiers = @dossiers_a_traiter params[:page] = 1 if params[:page].nil? @@ -91,7 +95,7 @@ class Users::DossiersController < UsersController end def en_attente - @dossiers_en_attente = current_user.dossiers.waiting_for_gestionnaire + @dossiers_en_attente = current_user.dossiers.waiting_for_gestionnaire 'DESC' @dossiers = @dossiers_en_attente params[:page] = 1 if params[:page].nil? @@ -101,7 +105,7 @@ class Users::DossiersController < UsersController end def termine - @dossiers_termine = current_user.dossiers.termine + @dossiers_termine = current_user.dossiers.termine 'DESC' @dossiers = @dossiers_termine params[:page] = 1 if params[:page].nil? @@ -133,8 +137,8 @@ class Users::DossiersController < UsersController end def total_dossiers_per_state - @dossiers_a_traiter_total = !@dossiers_a_traiter.nil? ? @dossiers_a_traiter.size : current_user.dossiers.waiting_for_user().size - @dossiers_en_attente_total = !@dossiers_en_attente.nil? ? @dossiers_en_attente.size : current_user.dossiers.waiting_for_gestionnaire().size - @dossiers_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : current_user.dossiers.termine().size + @dossiers_a_traiter_total = !@dossiers_a_traiter.nil? ? @dossiers_a_traiter.size : current_user.dossiers.waiting_for_user.size + @dossiers_en_attente_total = !@dossiers_en_attente.nil? ? @dossiers_en_attente.size : current_user.dossiers.waiting_for_gestionnaire.size + @dossiers_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : current_user.dossiers.termine.size end end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 229a37fef..5ad6871a3 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -133,16 +133,16 @@ class Dossier < ActiveRecord::Base TERMINE.include?(state) end - def self.waiting_for_gestionnaire - where(state: WAITING_FOR_GESTIONNAIRE, archived: false).order('updated_at ASC') + def self.waiting_for_gestionnaire order = 'ASC' + where(state: WAITING_FOR_GESTIONNAIRE, archived: false).order("updated_at #{order}") end - def self.waiting_for_user - where(state: WAITING_FOR_USER, archived: false).order('updated_at ASC') + def self.waiting_for_user order = 'ASC' + where(state: WAITING_FOR_USER, archived: false).order("updated_at #{order}") end - def self.termine - where(state: TERMINE, archived: false).order('updated_at ASC') + def self.termine order = 'ASC' + where(state: TERMINE, archived: false).order("updated_at #{order}") end def self.search current_gestionnaire, terms diff --git a/spec/features/france_connect/france_connect_spec.rb b/spec/features/france_connect/france_connect_spec.rb index dc5c2b3aa..2f82fb0fd 100644 --- a/spec/features/france_connect/france_connect_spec.rb +++ b/spec/features/france_connect/france_connect_spec.rb @@ -23,7 +23,7 @@ feature 'France Connect Connexion' do end scenario 'he is redirected to france connect' do - expect(page).to have_content('Vos dossiers') + expect(page).to have_content('Mes dossiers') end end @@ -63,7 +63,7 @@ feature 'France Connect Connexion' do context 'when starting page is dossiers list' do let(:initial_path) { users_dossiers_path } scenario 'he is redirected to dossier list' do - expect(page).to have_css('#users_dossiers_index') + expect(page).to have_css('#users_a_traiter') end end context 'when starting page is procedure' do diff --git a/spec/features/users/list_dossiers_spec.rb b/spec/features/users/list_dossiers_spec.rb index e989e70a7..d72664cfe 100644 --- a/spec/features/users/list_dossiers_spec.rb +++ b/spec/features/users/list_dossiers_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' feature 'user access to the list of his dossier' do let(:user) { create(:user) } - let!(:last_updated_dossier) { create(:dossier, :with_procedure, user: user, state: 'initiated')} - let!(:dossier1) { create(:dossier, :with_procedure, user: user, nom_projet: 'mon permier dossier', state: 'initiated') } + let!(:last_updated_dossier) { create(:dossier, :with_procedure, user: user, state: 'replied')} + let!(:dossier1) { create(:dossier, :with_procedure, user: user, nom_projet: 'mon permier dossier', state: 'replied') } let!(:dossier2) { create(:dossier, :with_user, nom_projet: 'mon deuxième dossier') } before do