Merge pull request #5192 from betagouv/dev

2020-05-26-01
This commit is contained in:
krichtof 2020-05-26 18:47:25 +02:00 committed by GitHub
commit d06ef02f67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 34 additions and 54 deletions

View file

@ -50,7 +50,7 @@ class Champs::SiretController < ApplicationController
end end
def find_etablissement_with_siret def find_etablissement_with_siret
ApiEntrepriseService.create_etablissement(@champ.dossier, @siret, current_user.id) ApiEntrepriseService.create_etablissement(@champ, @siret, current_user.id)
end end
def clear_siret_and_etablissement def clear_siret_and_etablissement

View file

@ -74,11 +74,11 @@ class ApiEntreprise::API
if response.success? if response.success?
JSON.parse(response.body, symbolize_names: true) JSON.parse(response.body, symbolize_names: true)
elsif response.code&.between?(401, 499) elsif response.code&.between?(401, 499)
raise ResourceNotFound raise ResourceNotFound, "url: #{url}"
elsif response.code == 400 elsif response.code == 400
raise BadFormatRequest raise BadFormatRequest, "url: #{url}"
else else
raise RequestFailed, "HTTP Error Code: #{response.code}" raise RequestFailed, "HTTP Error Code: #{response.code} for #{url}"
end end
end end

View file

@ -11,7 +11,7 @@ class Champ < ApplicationRecord
belongs_to :etablissement, dependent: :destroy belongs_to :etablissement, dependent: :destroy
has_many :champs, -> { ordered }, foreign_key: :parent_id, inverse_of: :parent, dependent: :destroy has_many :champs, -> { ordered }, foreign_key: :parent_id, inverse_of: :parent, dependent: :destroy
delegate :libelle, :type_champ, :order_place, :mandatory?, :description, :drop_down_list, :exclude_from_export?, :exclude_from_view?, :repetition?, :dossier_link?, to: :type_de_champ delegate :libelle, :type_champ, :procedure, :order_place, :mandatory?, :description, :drop_down_list, :exclude_from_export?, :exclude_from_view?, :repetition?, :dossier_link?, to: :type_de_champ
scope :updated_since?, -> (date) { where('champs.updated_at > ?', date) } scope :updated_since?, -> (date) { where('champs.updated_at > ?', date) }
scope :public_only, -> { where(private: false) } scope :public_only, -> { where(private: false) }

View file

@ -7,11 +7,11 @@ class ApiEntrepriseService
# #
# Raises a ApiEntreprise::API::RequestFailed exception on transient errors # Raises a ApiEntreprise::API::RequestFailed exception on transient errors
# (timeout, 5XX HTTP error code, etc.) # (timeout, 5XX HTTP error code, etc.)
def self.create_etablissement(dossier, siret, user_id = nil) def self.create_etablissement(dossier_or_champ, siret, user_id = nil)
etablissement_params = ApiEntreprise::EtablissementAdapter.new(siret, dossier.procedure.id).to_params etablissement_params = ApiEntreprise::EtablissementAdapter.new(siret, dossier_or_champ.procedure.id).to_params
return nil if etablissement_params.empty? return nil if etablissement_params.empty?
etablissement = dossier.build_etablissement(etablissement_params) etablissement = dossier_or_champ.build_etablissement(etablissement_params)
etablissement.save etablissement.save
[ [
@ -19,9 +19,9 @@ class ApiEntrepriseService
ApiEntreprise::EffectifsJob, ApiEntreprise::EffectifsAnnuelsJob, ApiEntreprise::AttestationSocialeJob, ApiEntreprise::EffectifsJob, ApiEntreprise::EffectifsAnnuelsJob, ApiEntreprise::AttestationSocialeJob,
ApiEntreprise::BilansBdfJob ApiEntreprise::BilansBdfJob
].each do |job| ].each do |job|
job.perform_later(etablissement.id, dossier.procedure.id) job.perform_later(etablissement.id, dossier_or_champ.procedure.id)
end end
ApiEntreprise::AttestationFiscaleJob.perform_later(etablissement.id, dossier.procedure.id, user_id) ApiEntreprise::AttestationFiscaleJob.perform_later(etablissement.id, dossier_or_champ.procedure.id, user_id)
etablissement etablissement
end end

View file

@ -23,23 +23,27 @@
%br %br
Il est donc important que les usagers puissent vous contacter s'ils ont des questions sur votre démarche. Il est donc important que les usagers puissent vous contacter s'ils ont des questions sur votre démarche.
%br %br
Ces informations seront visibles par les utilisateurs de la démarche, affichées dans le menu "Aide". Ces informations seront visibles par les utilisateurs de la démarche, affichées dans le menu "Aide", ainsi qu'en pied de page lors du dépot d'un dossier.
%p.explication Indiquez une adresse mail en capacité de répondre à l'usager.
= f.label :email do = f.label :email do
Adresse email Adresse email
%span.mandatory * %span.mandatory *
%p.explication
Indiquer une adresse email <strong>valide</strong> est indispensable pour publier votre démarche.
Cette adresse email doit permettre de recevoir les questions des usagers.
= f.email_field :email, placeholder: 'contact@mon-service.fr', required: true = f.email_field :email, placeholder: 'contact@mon-service.fr', required: true
%p.explication Indiquez le numéro de téléphone du service le plus à même de fournir des réponses pertinentes à vos usagers.
= f.label :telephone do = f.label :telephone do
%span.mandatory *
Numéro de téléphone Numéro de téléphone
%span.mandatory *
%p.explication Indiquez le numéro de téléphone du service <strong>valide</strong> le plus à même de fournir des réponses pertinentes à vos usagers aux horaires où vous êtes joignables.
= f.telephone_field :telephone, placeholder: '04 12 24 42 37', required: true = f.telephone_field :telephone, placeholder: '04 12 24 42 37', required: true
= f.label :horaires do = f.label :horaires do
Horaires Horaires
%span.mandatory * %span.mandatory *
%p.explication Indiquez les horaires où les usagers peuvent vous joindre.
= f.text_area :horaires, placeholder: "Du lundi au vendredi de 9 h 30 à 17 h 30. Le samedi de 9 h 30 à 12 h.", required: true = f.text_area :horaires, placeholder: "Du lundi au vendredi de 9 h 30 à 17 h 30. Le samedi de 9 h 30 à 12 h.", required: true
= f.label :adresse do = f.label :adresse do

View file

@ -23,9 +23,14 @@
%hr.confirmation-separator %hr.confirmation-separator
.confirmation-resend .confirmation-resend
%p Si vous navez pas reçu notre message, nous pouvons vous le renvoyer. %p Si vous navez pas reçu notre message (avez-vous vérifié les indésirables ?), nous pouvons vous le renvoyer.
= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { class: 'form' }) do |f| = form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { class: 'form' }) do |f|
= f.label :email, 'Email' = f.label :email, 'Email'
= f.email_field :email, placeholder: 'Email', class: 'small', autofocus: true = f.email_field :email, placeholder: 'Email', class: 'small', autofocus: true
= f.submit 'Renvoyer un email de confirmation', class: 'button' = f.submit 'Renvoyer un email de confirmation', class: 'button'
%p
Vous pouvez également consulter notre
= link_to('FAQ', "https://faq.demarches-simplifiees.fr/article/79-je-ne-recois-pas-demail", target: '_blank', rel: 'noopener')
\.

View file

@ -15,6 +15,8 @@ development:
host: <%= ENV["DB_HOST"] %> host: <%= ENV["DB_HOST"] %>
username: <%= ENV["DB_USERNAME"] %> username: <%= ENV["DB_USERNAME"] %>
password: <%= ENV["DB_PASSWORD"] %> password: <%= ENV["DB_PASSWORD"] %>
# Workaround for https://github.com/ged/ruby-pg/issues/311
gssencmode: disable
test: test:
<<: *default <<: *default
@ -22,6 +24,8 @@ test:
host: localhost host: localhost
username: tps_test username: tps_test
password: tps_test password: tps_test
# Workaround for https://github.com/ged/ruby-pg/issues/311
gssencmode: disable
production: &production production: &production
<<: *default <<: *default

View file

@ -4,7 +4,11 @@ describe Champs::SiretController, type: :controller do
describe '#show' do describe '#show' do
let(:dossier) { create(:dossier, user: user, procedure: procedure) } let(:dossier) { create(:dossier, user: user, procedure: procedure) }
let(:champ) { create(:champ_siret, dossier: dossier, value: nil, etablissement: nil) } let(:champ) do
d = dossier
type_de_champ = create(:type_de_champ_siret, procedure: procedure)
type_de_champ.champ.create(dossier: d, value: nil, etablissement: nil)
end
let(:params) do let(:params) do
{ {
champ_id: champ.id, champ_id: champ.id,
@ -109,6 +113,7 @@ describe Champs::SiretController, type: :controller do
expect(champ.value).to eq(siret) expect(champ.value).to eq(siret)
expect(champ.etablissement.siret).to eq(siret) expect(champ.etablissement.siret).to eq(siret)
expect(champ.reload.etablissement.naf).to eq("6202A") expect(champ.reload.etablissement.naf).to eq("6202A")
expect(dossier.reload.etablissement).to eq(nil)
end end
end end
end end

View file

@ -1,38 +0,0 @@
describe ActiveStorage::Service::DsProxyService do
let(:private_host) { 'storage.sbg1.cloud.ovh.net:443' }
let(:public_host) { 'static.demarches-simplifiees.fr' }
let(:auth) { 'AUTH_a24c37ed11a84896914514384898c34b' }
let(:bucket) { 'test_local' }
let(:key) { '2R6rr89nFeSRkSgXHd3smvEf' }
let(:temp_url_params) { 'temp_url_sig=5ab8cfc3ba5da2598a6c88cc6b1b461fe4e115bc&temp_url_expires=1547598179' }
let(:storage_service) { storage_service = double(ActiveStorage::Service) }
subject { ActiveStorage::Service::DsProxyService.new(wrapped: storage_service) }
describe '#url' do
let(:private_url) { "https://#{private_host}/v1/#{auth}/#{bucket}/#{key}?#{temp_url_params}" }
let(:public_url) { "https://#{public_host}/#{bucket}/#{key}?#{temp_url_params}" }
before do
expect(storage_service).to receive(:url).and_return(private_url)
end
it 'rewrites the host and removes the "v1/auth..." prefix of the storage URL' do
expect(subject.url(key)).to eq(public_url)
end
end
describe '#url_for_direct_upload' do
let(:download_params) { 'inline&filename=documents_top_confidentiels.bmp' }
let(:private_url) { "https://#{private_host}/v1/#{auth}/#{bucket}/#{key}?#{temp_url_params}&#{download_params}" }
let(:public_url) { "https://#{public_host}/#{bucket}/#{key}?#{temp_url_params}&#{download_params}" }
before do
expect(storage_service).to receive(:url_for_direct_upload).and_return(private_url)
end
it 'rewrites the host and removes the "v1/auth..." prefix of the storage URL' do
expect(subject.url_for_direct_upload(key)).to eq(public_url)
end
end
end