Add ProcedureController tests
This commit is contained in:
parent
24e0768961
commit
ee82e7fa8a
2 changed files with 40 additions and 2 deletions
|
@ -7,14 +7,14 @@ class Backoffice::Dossiers::ProcedureController < Backoffice::DossiersListContro
|
||||||
|
|
||||||
render 'backoffice/dossiers/index'
|
render 'backoffice/dossiers/index'
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
flash[:alert] = "Cette procédure n'existe pas ou vous n'y avez pas accès."
|
flash.alert = "Cette procédure n'existe pas ou vous n'y avez pas accès."
|
||||||
redirect_to backoffice_dossiers_path
|
redirect_to backoffice_dossiers_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter
|
def filter
|
||||||
super
|
super
|
||||||
|
|
||||||
redirect_to backoffice_dossiers_procedure_path(id: params[:id], liste: param_liste)
|
redirect_to backoffice_dossiers_procedure_path(id: params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Backoffice::Dossiers::ProcedureController, type: :controller do
|
||||||
|
let(:gestionnaire) { create :gestionnaire }
|
||||||
|
let(:procedure) { create :procedure }
|
||||||
|
|
||||||
|
before do
|
||||||
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||||
|
sign_in gestionnaire
|
||||||
|
gestionnaire.build_default_preferences_list_dossier procedure.id
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'GET #index' do
|
||||||
|
let(:procedure_id) { procedure.id }
|
||||||
|
|
||||||
|
subject { get :index, params: {id: procedure_id} }
|
||||||
|
|
||||||
|
it { expect(subject.status).to eq 200 }
|
||||||
|
|
||||||
|
context 'when procedure id is not found' do
|
||||||
|
let(:procedure_id) { 100000 }
|
||||||
|
|
||||||
|
before do
|
||||||
|
subject
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(response.status).to eq 302 }
|
||||||
|
it { is_expected.to redirect_to backoffice_dossiers_path }
|
||||||
|
it { expect(flash[:alert]).to be_present}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'GET #filter' do
|
||||||
|
subject { get :filter, params: {id: procedure.id, filter_input: {"entreprise.raison_sociale" => "plop"}} }
|
||||||
|
|
||||||
|
it { is_expected.to redirect_to backoffice_dossiers_procedure_path(id: procedure.id) }
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue