- Redirect User dossier index to User dossier a traiter

- Fix tests
- Order file list by last updated for User
This commit is contained in:
Xavier J 2015-11-30 15:56:06 +01:00
parent da49c633dc
commit 58f840ac92
4 changed files with 20 additions and 16 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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