User can see archived file in principal list

This commit is contained in:
Xavier J 2015-11-27 15:04:44 +01:00
parent 1e1a6b3693
commit e9012d8164
3 changed files with 11 additions and 4 deletions

View file

@ -2,7 +2,7 @@ class Users::DossiersController < UsersController
before_action :authenticate_user!
def index
@dossiers = current_user.dossiers.where("state NOT IN ('draft')").order(updated_at: 'DESC')
@dossiers = current_user.dossiers.where.not(state: :draft).where(archived: false).order(updated_at: 'DESC')
if params[:page].nil?
params[:page] = 1

View file

@ -3,12 +3,14 @@ require 'spec_helper'
describe Users::DossiersController, type: :controller do
let(:user) { create(:user) }
describe '.index' do
describe 'GET #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') }
end
context 'when user is logged in' do
before do
sign_in create(:user)

View file

@ -6,15 +6,20 @@ describe 'users/dossiers/index.html.haml', type: :view do
let(:user) { create(:user) }
let!(:dossier1) { create(:dossier, :with_procedure, user: user, state: 'initiated') }
let!(:dossier2) { create(:dossier, :with_procedure, user: user, state: 'initiated') }
let(:dossiers) { user.dossiers.where("state NOT IN ('draft')").order(updated_at: 'DESC') }
let!(:dossier2) { create(:dossier, :with_procedure, user: user, nom_projet: 'projet de test', state: 'draft') }
let!(:dossier3) { create(:dossier, :with_procedure, user: user, nom_projet: 'projet de test 2', state: 'initiated', archived: true) }
let(:dossiers) { user.dossiers.where.not(state: :draft).where(archived: false).order(updated_at: 'DESC') }
before do
assign(:dossiers, dossiers.paginate(:page => params[:page], :per_page => 12).decorate)
render
end
subject { rendered }
it { expect(subject).to have_content(dossier1.nom_projet) }
it { expect(subject).not_to have_content(dossier2.nom_projet) }
it { expect(subject).not_to have_content(dossier3.nom_projet) }
end
end