From 1dc413e313e44b99c60c9703e1829bc7d3c917e8 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Thu, 8 Feb 2018 15:41:52 +0100 Subject: [PATCH 1/3] [Fix #1383] Force french language for apidoc Also fixes #1389, #1392 and #1398 --- config/initializers/apipie.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/initializers/apipie.rb b/config/initializers/apipie.rb index 4609310f2..61e012d19 100644 --- a/config/initializers/apipie.rb +++ b/config/initializers/apipie.rb @@ -9,6 +9,9 @@ Apipie.configure do |config| config.namespaced_resources = true config.show_all_examples = true + config.languages = ['fr'] + config.default_locale = 'fr' + config.app_info = <<~EOS Description From fe4e57af6c07871070d05674ce7a3d5aaf3ff734 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Thu, 8 Feb 2018 16:20:32 +0100 Subject: [PATCH 2/3] [Fix #1389] Force French language In #1383, a misconfigured gem was corrupting a global I18n variable that was persisten across requests, resulting in #1389, #1392 and #1398. This commit prevents future corruptions of locales. --- config/application.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/application.rb b/config/application.rb index b8663e17c..620d997e1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -20,6 +20,7 @@ module TPS # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] config.i18n.default_locale = :fr config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] + config.i18n.available_locales = [:fr] config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/validators #{config.root}/app/facades) config.assets.paths << Rails.root.join('app', 'assets', 'javascript') From 283e6e927b52fc234f9861429456a85c0ece0aad Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Wed, 7 Feb 2018 20:30:12 +0100 Subject: [PATCH 3/3] [Fix #1397] Hide 'envoyer' button when no potential recipient --- .../dossiers/_envoyer_dossier_block.html.haml | 12 ++++++--- .../_envoyer_dossier_block.html.haml_spec.rb | 27 +++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb diff --git a/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml b/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml index cf5d33eac..fe4b705d8 100644 --- a/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml +++ b/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml @@ -1,6 +1,10 @@ .tab-title= "Envoyer ce dossier à un autre accompagnateur" -= form_for dossier, url: envoyer_a_accompagnateur_dossier_path(dossier.procedure, dossier), method: :post, html: { class: 'form' } do |f| - .flex.justify-start.align-baseline - = select_tag(:recipient, options_from_collection_for_select(potential_recipients, :id, :email)) - = f.submit "Envoyer", class: "button large send gap-left" +- if potential_recipients.empty? + %p.tab-paragraph + Vous êtes le seul accompagnateur assigné sur cette procédure +- else + = form_for dossier, url: envoyer_a_accompagnateur_dossier_path(dossier.procedure, dossier), method: :post, html: { class: 'form' } do |f| + .flex.justify-start.align-baseline + = select_tag(:recipient, options_from_collection_for_select(potential_recipients, :id, :email)) + = f.submit "Envoyer", class: "button large send gap-left" diff --git a/spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb b/spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb new file mode 100644 index 000000000..8f8222e91 --- /dev/null +++ b/spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb @@ -0,0 +1,27 @@ +describe 'new_gestionnaire/dossiers/envoyer_dossier_block.html.haml', type: :view do + let(:dossier) { create(:dossier) } + + subject do + render( + 'new_gestionnaire/dossiers/envoyer_dossier_block.html.haml', + dossier: dossier, + potential_recipients: potential_recipients, + ) + end + + context "there are other gestionnaires for the procedure" do + let(:gestionnaire) { create(:gestionnaire, email: 'yop@totomail.fr') } + let(:potential_recipients) { [gestionnaire] } + + it { is_expected.to have_css("select > option[value='#{gestionnaire.id}']") } + it { is_expected.to have_css(".button.send") } + end + + context "there is no other gestionnaire for the procedure" do + let(:potential_recipients) { [] } + + it { is_expected.not_to have_css("select") } + it { is_expected.not_to have_css(".button.send") } + it { is_expected.to have_content("Vous êtes le seul accompagnateur assigné sur cette procédure") } + end +end