[#890] order dossier for user by last update
This commit is contained in:
parent
170655a72b
commit
92d5fb4cf3
3 changed files with 9 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
class Users::DossiersController < UsersController
|
||||
before_action :authenticate_user!
|
||||
def index
|
||||
@dossiers = current_user.dossiers.decorate
|
||||
@dossiers = current_user.dossiers.order(updated_at: 'DESC').decorate
|
||||
end
|
||||
def show
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ require 'spec_helper'
|
|||
describe Users::DossiersController, type: :controller do
|
||||
let(:user) { create(:user) }
|
||||
describe '.index' do
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, user: user) }
|
||||
subject { get :index }
|
||||
context 'when user is not logged in' do
|
||||
it { is_expected.to redirect_to('/users/sign_in') }
|
||||
|
|
|
@ -3,9 +3,11 @@ 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)}
|
||||
let!(:dossier1) { create(:dossier, :with_procedure, user: user, nom_projet: 'mon permier dossier') }
|
||||
let!(:dossier2) { create(:dossier, :with_user, nom_projet: 'mon deuxième dossier') }
|
||||
before do
|
||||
last_updated_dossier.update_attributes(nom_projet: 'salut la compagnie')
|
||||
visit root_path
|
||||
page.find_by_id('user_email').set user.email
|
||||
page.find_by_id('user_password').set user.password
|
||||
|
@ -15,6 +17,11 @@ feature 'user access to the list of his dossier' do
|
|||
expect(page).to have_content(dossier1.nom_projet)
|
||||
expect(page).not_to have_content(dossier2.nom_projet)
|
||||
end
|
||||
|
||||
scenario 'the list must be order by last updated' do
|
||||
expect(page.body).to match(/#{last_updated_dossier.nom_projet}.*#{dossier1.nom_projet}/m)
|
||||
end
|
||||
|
||||
context 'when user clicks on a projet in list' do
|
||||
before do
|
||||
page.click_on dossier1.nom_projet
|
||||
|
|
Loading…
Reference in a new issue