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