From c1b71b1b5484dfc7beb7aa9f55e0fd696253f26a Mon Sep 17 00:00:00 2001 From: Tanguy PATTE Date: Thu, 24 Sep 2015 11:45:28 +0200 Subject: [PATCH] [#887] filter user dossier list --- app/controllers/users/dossiers_controller.rb | 2 +- spec/features/users/list_dossiers_spec.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 05dd2442e..29d476dfa 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -1,7 +1,7 @@ class Users::DossiersController < UsersController before_action :authenticate_user! def index - @dossiers = Dossier.all.decorate + @dossiers = current_user.dossiers.decorate end def show diff --git a/spec/features/users/list_dossiers_spec.rb b/spec/features/users/list_dossiers_spec.rb index 1ec982396..bd754e769 100644 --- a/spec/features/users/list_dossiers_spec.rb +++ b/spec/features/users/list_dossiers_spec.rb @@ -3,7 +3,8 @@ require 'spec_helper' feature 'user access to the list of his dossier' do let(:user) { create(:user) } - let!(:dossier1) { create(:dossier, :with_user) } + let!(:dossier1) { create(:dossier, user: user, nom_projet: 'mon permier dossier') } + let!(:dossier2) { create(:dossier, :with_user, nom_projet: 'mon deuxième dossier') } before do visit root_path page.find_by_id('user_email').set user.email @@ -12,5 +13,6 @@ feature 'user access to the list of his dossier' do end scenario 'the list of dossier is displayed' do expect(page).to have_content(dossier1.nom_projet) + expect(page).not_to have_content(dossier2.nom_projet) end end \ No newline at end of file