Gestionnaire can't access to a archived file with direct URL

This commit is contained in:
Xavier J 2015-11-27 15:09:16 +01:00
parent e9012d8164
commit 3fd7e6b6c0
2 changed files with 8 additions and 1 deletions

View file

@ -67,7 +67,7 @@ class Backoffice::DossiersController < ApplicationController
end
def initialize_instance_params dossier_id
@dossier = Dossier.find(dossier_id)
@dossier = Dossier.where(archived: false).find(dossier_id)
@entreprise = @dossier.entreprise.decorate
@etablissement = @dossier.etablissement
@pieces_justificatives = @dossier.pieces_justificatives

View file

@ -2,6 +2,8 @@ require 'rails_helper'
describe Backoffice::DossiersController, type: :controller do
let(:dossier) { create(:dossier, :with_entreprise, :with_user) }
let(:dossier_archived) { create(:dossier, :with_entreprise, :with_user, archived: true) }
let(:dossier_id) { dossier.id }
let(:bad_dossier_id) { Dossier.count + 10 }
let(:gestionnaire) { create(:gestionnaire, administrateur: create(:administrateur)) }
@ -17,6 +19,11 @@ describe Backoffice::DossiersController, type: :controller do
expect(response).to have_http_status(200)
end
it 'dossier is archived' do
get :show, id: dossier_archived
expect(response).to redirect_to('/backoffice')
end
it 'dossier id doesnt exist' do
get :show, id: bad_dossier_id
expect(response).to redirect_to('/backoffice')