Merge branch 'staging'
This commit is contained in:
commit
243065e77c
9 changed files with 105 additions and 37 deletions
|
@ -7,6 +7,10 @@ function action_type_de_champs() {
|
|||
toggleErrorClass(this, validateEmail($(this).val()));
|
||||
});
|
||||
|
||||
$("input[type='number']").on('change', function () {
|
||||
toggleErrorClass(this, validateNumber($(this).val()));
|
||||
});
|
||||
|
||||
$("input[type='phone']").on('change', function () {
|
||||
val = $(this).val();
|
||||
val = val.replace(/[ ]/g, '');
|
||||
|
@ -43,6 +47,11 @@ function validateEmail(email) {
|
|||
return validateInput(email, re)
|
||||
}
|
||||
|
||||
function validateNumber(number) {
|
||||
var re = /^[0-9]+$/;
|
||||
return validateInput(number, re)
|
||||
}
|
||||
|
||||
function validateInput(input, regex) {
|
||||
return regex.test(input);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,11 @@ class Users::DescriptionController < UsersController
|
|||
authorized_routes? self.class
|
||||
end
|
||||
|
||||
before_action :check_autorisation_donnees, only: [:show]
|
||||
before_action :check_starter_dossier_informations, only: [:show]
|
||||
|
||||
def show
|
||||
@dossier = current_user_dossier.decorate
|
||||
@dossier ||= current_user_dossier.decorate
|
||||
|
||||
@procedure = @dossier.procedure
|
||||
@champs = @dossier.ordered_champs
|
||||
|
@ -83,6 +86,7 @@ class Users::DescriptionController < UsersController
|
|||
flash.alert = errors_upload.html_safe
|
||||
else
|
||||
flash.notice = 'Nouveaux fichiers envoyés'
|
||||
@dossier.next_step! 'user', 'update'
|
||||
end
|
||||
|
||||
return redirect_to users_dossiers_invite_path(id: current_user.invites.find_by_dossier_id(@dossier.id).id) if invite
|
||||
|
@ -98,6 +102,21 @@ class Users::DescriptionController < UsersController
|
|||
|
||||
private
|
||||
|
||||
def check_autorisation_donnees
|
||||
@dossier ||= current_user_dossier
|
||||
|
||||
redirect_to url_for(users_dossier_path(@dossier.id)) if @dossier.autorisation_donnees.nil? || !@dossier.autorisation_donnees
|
||||
end
|
||||
|
||||
def check_starter_dossier_informations
|
||||
@dossier ||= current_user_dossier
|
||||
|
||||
if (@dossier.procedure.for_individual? && @dossier.individual.nil?) ||
|
||||
(!@dossier.procedure.for_individual? && @dossier.entreprise.nil?)
|
||||
redirect_to url_for(users_dossier_path(@dossier.id))
|
||||
end
|
||||
end
|
||||
|
||||
def create_params
|
||||
params.permit()
|
||||
end
|
||||
|
|
15
app/uploaders/base_uploader.rb
Normal file
15
app/uploaders/base_uploader.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
# encoding: utf-8
|
||||
|
||||
class BaseUploader < CarrierWave::Uploader::Base
|
||||
def cache_dir
|
||||
if Rails.env.production?
|
||||
if Features.opensimplif?
|
||||
'/tmp/opensimplif-cache'
|
||||
else
|
||||
'/tmp/tps-cache'
|
||||
end
|
||||
else
|
||||
'/tmp/tps-dev-cache'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
# encoding: utf-8
|
||||
|
||||
class CerfaUploader < CarrierWave::Uploader::Base
|
||||
class CerfaUploader < BaseUploader
|
||||
before :cache, :set_original_filename
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
|
@ -18,14 +18,6 @@ class CerfaUploader < CarrierWave::Uploader::Base
|
|||
end
|
||||
end
|
||||
|
||||
def cache_dir
|
||||
if Rails.env.production?
|
||||
'/tmp/tps-cache'
|
||||
else
|
||||
'/tmp/tps-dev-cache'
|
||||
end
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# encoding: utf-8
|
||||
|
||||
class PieceJustificativeUploader < CarrierWave::Uploader::Base
|
||||
class PieceJustificativeUploader < BaseUploader
|
||||
before :cache, :set_original_filename
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
|
@ -18,18 +18,6 @@ class PieceJustificativeUploader < CarrierWave::Uploader::Base
|
|||
end
|
||||
end
|
||||
|
||||
def cache_dir
|
||||
if Rails.env.production?
|
||||
if Features.opensimplif?
|
||||
'/tmp/opensimplif-cache'
|
||||
else
|
||||
'/tmp/tps-cache'
|
||||
end
|
||||
else
|
||||
'/tmp/tps-dev-cache'
|
||||
end
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# encoding: utf-8
|
||||
|
||||
class ProcedureLogoUploader < CarrierWave::Uploader::Base
|
||||
class ProcedureLogoUploader < BaseUploader
|
||||
|
||||
def root
|
||||
File.join(Rails.root, "public")
|
||||
|
@ -21,14 +21,6 @@ class ProcedureLogoUploader < CarrierWave::Uploader::Base
|
|||
end
|
||||
end
|
||||
|
||||
def cache_dir
|
||||
if Rails.env.production?
|
||||
'/tmp/tps-cache'
|
||||
else
|
||||
'/tmp/tps-dev-cache'
|
||||
end
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
|
|
|
@ -51,6 +51,8 @@ fr:
|
|||
size_too_big: "La taille du fichier joint est trop importante. Elle doit être inférieure à 3Mo."
|
||||
user:
|
||||
attributes:
|
||||
reset_password_token:
|
||||
invalid: ": Votre lien de nouveau mot de passe a expiré. Merci d'en demander un nouveau."
|
||||
email:
|
||||
invalid: invalide
|
||||
taken: déjà utilisé
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
shared_examples 'description_controller_spec' do
|
||||
describe 'GET #show' do
|
||||
before do
|
||||
dossier.update_column :autorisation_donnees, true
|
||||
end
|
||||
context 'user is not connected' do
|
||||
before do
|
||||
sign_out dossier.user
|
||||
|
@ -11,9 +14,15 @@ shared_examples 'description_controller_spec' do
|
|||
end
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
get :show, dossier_id: dossier_id
|
||||
expect(response).to have_http_status(:success)
|
||||
context 'when all is ok' do
|
||||
before do
|
||||
dossier.entreprise = create :entreprise
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
get :show, dossier_id: dossier_id
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
it 'redirection vers start si mauvais dossier ID' do
|
||||
|
@ -35,6 +44,48 @@ shared_examples 'description_controller_spec' do
|
|||
it { is_expected.to redirect_to root_path }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'before action check_autorisation_donnees' do
|
||||
subject { get :show, dossier_id: dossier_id }
|
||||
|
||||
context 'when dossier does not have a valid autorisations_donness (nil)' do
|
||||
before do
|
||||
dossier.update_column :autorisation_donnees, nil
|
||||
end
|
||||
|
||||
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
|
||||
end
|
||||
|
||||
context 'when dossier does not have a valid autorisations_donness (false)' do
|
||||
before do
|
||||
dossier.update_column :autorisation_donnees, false
|
||||
end
|
||||
|
||||
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'before action check_starter_dossier_informations' do
|
||||
subject { get :show, dossier_id: dossier_id }
|
||||
|
||||
context 'when dossier does not have an enterprise datas' do
|
||||
before do
|
||||
|
||||
end
|
||||
|
||||
it { expect(dossier.entreprise).to be_nil }
|
||||
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
|
||||
end
|
||||
|
||||
context 'when dossier does not have an individual datas' do
|
||||
before do
|
||||
procedure.update_column :for_individual, true
|
||||
end
|
||||
|
||||
it { expect(dossier.individual).to be_nil }
|
||||
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
feature 'user is on description page' do
|
||||
let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: true) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, autorisation_donnees: true) }
|
||||
|
||||
before do
|
||||
allow(ClamavService).to receive(:safe_file?).and_return(true)
|
||||
|
|
Loading…
Reference in a new issue