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

View file

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

View file

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

View file

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

View file

@ -35,7 +35,7 @@ describe Admin::ProceduresController, type: :controller do
end end
describe 'GET #show' do 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 } let(:procedure_id) { procedure.id }
subject { get :show, id: procedure_id } subject { get :show, id: procedure_id }
@ -115,7 +115,7 @@ describe Admin::ProceduresController, type: :controller do
end end
describe 'PUT #update' do 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 context 'when administrateur is not connected' do
before do before do

View file

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

View file

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