demarches-normaliennes/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb

38 lines
1.1 KiB
Ruby
Raw Normal View History

2016-12-16 17:15:13 +01:00
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