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