User can begin a new dossier with a procedure archived

Administrateur can see archived procedure
This commit is contained in:
Xavier J 2015-11-27 10:39:05 +01:00
parent 833752161f
commit dd09a38bbb
7 changed files with 26 additions and 26 deletions

View file

@ -1,12 +1,12 @@
class Admin::ProceduresController < AdminController
def index
@procedures = current_administrateur.procedures
@procedures = current_administrateur.procedures.where(archived: false)
@procedures = @procedures.paginate(:page => params[:page], :per_page => 12)
end
def show
@procedure = Procedure.find(params[:id])
@procedure = current_administrateur.procedures.find(params[:id])
@types_de_champ = @procedure.types_de_champ.order(:order_place)
@types_de_piece_justificative = @procedure.types_de_piece_justificative.order(:libelle)
@ -33,7 +33,7 @@ class Admin::ProceduresController < AdminController
def update
@procedure = Procedure.find(params[:id])
@procedure = current_administrateur.procedures.find(params[:id])
unless @procedure.update_attributes(create_procedure_params)
flash.now.alert = @procedure.errors.full_messages.join('<br />').html_safe

View file

@ -1,6 +1,6 @@
class Users::ProcedureController < UsersController
def index
@procedure = Procedure.find(params[:procedure_id])
@procedure = Procedure.where(archived: false).find(params[:procedure_id])
@siret = params[:siret] || current_user.siret
rescue ActiveRecord::RecordNotFound
error_procedure

View file

@ -1,15 +1,9 @@
class Users::SiretController < UsersController
def index
@procedure = Procedure.find(params['procedure_id'])
@siret = params[:siret] || current_user.siret
redirect_to(users_path(procedure_id: @procedure, siret: @siret))
rescue ActiveRecord::RecordNotFound
error_procedure
end
def error_procedure
render :file => "#{Rails.root}/public/404_procedure_not_found.html", :status => 404
redirect_to(users_path(procedure_id: params['procedure_id'], siret: @siret))
rescue ActionController::UrlGenerationError
redirect_to(new_user_session_path)
end
end

View file

@ -6,7 +6,7 @@
%td
%th Titre
%th Description
- Procedure.all.each do |procedure|
- Procedure.all.where(archived: false).each do |procedure|
%tr
%td.col-md-1.col-lg-1
%td.col-md-4.col-lg-4

View file

@ -35,7 +35,7 @@ describe Admin::ProceduresController, type: :controller do
end
describe 'GET #show' do
let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative) }
let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, administrateur: admin) }
let(:procedure_id) { procedure.id }
subject { get :show, id: procedure_id }
@ -115,7 +115,7 @@ describe Admin::ProceduresController, type: :controller do
end
describe 'PUT #update' do
let!(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative) }
let!(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, administrateur: admin) }
context 'when administrateur is not connected' do
before do

View file

@ -1,30 +1,36 @@
require 'spec_helper'
describe Users::ProcedureController, type: :controller do
let!(:procedure) { create(:procedure) }
let(:procedure) { create(:procedure) }
let(:procedure_id) { procedure.id }
describe 'GET #index' do
before do
get :index, procedure_id: procedure
end
subject { get :index, procedure_id: procedure_id }
context 'when params procedure_id is present' do
context 'when procedure_id is valid' do
context 'when user is logged in' do
before do
sign_in create(:user)
end
subject { get :index, procedure_id: procedure }
it { expect(subject).to have_http_status(:success) }
it { is_expected.to have_http_status(:success) }
context 'when procedure_id is not valid' do
let(:procedure) { '' }
let(:procedure_id) { 0 }
it { is_expected.to have_http_status(404) }
end
context 'when procedure is archived' do
let(:procedure) { create(:procedure, archived: 'true') }
it { is_expected.to have_http_status(404) }
end
end
context 'when user is not logged' do
it { expect(response).to have_http_status(302) }
it { is_expected.to have_http_status(302) }
end
end
end

View file

@ -26,11 +26,11 @@ describe Users::SiretController, type: :controller do
context 'when procedure_id is not valid' do
let(:procedure) { '' }
it { is_expected.to have_http_status(404) }
it { is_expected.to have_http_status(302) }
end
context 'when params procedure_id is not present' do
subject { get :index }
it { is_expected.to have_http_status(404) }
it { is_expected.to redirect_to new_user_session_path }
end
end
context 'when user is not logged' do