From 64b68e4d268bb93d679971d7d99885e5316d1a40 Mon Sep 17 00:00:00 2001 From: Adrien Di Pasquale Date: Thu, 30 Jan 2025 12:59:15 +0100 Subject: [PATCH] =?UTF-8?q?emp=C3=AAcher=20de=20mettre=20=C3=A0=C2=A0jour?= =?UTF-8?q?=20le=20motif=20d=E2=80=99un=20RDV?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin/rdvs_controller.rb | 2 +- .../features/agents/agent_can_update_rdv_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/rdvs_controller.rb b/app/controllers/admin/rdvs_controller.rb index 4abb37f704..105ee464ac 100644 --- a/app/controllers/admin/rdvs_controller.rb +++ b/app/controllers/admin/rdvs_controller.rb @@ -164,7 +164,7 @@ def set_rdv end def rdv_update_params - allowed_params = params.require(:rdv).permit(:motif_id, :status, :lieu_id, :duration_in_min, :starts_at, :context, :ignore_benign_errors, :max_participants_count, :name, + allowed_params = params.require(:rdv).permit(:status, :lieu_id, :duration_in_min, :starts_at, :context, :ignore_benign_errors, :max_participants_count, :name, participations_attributes: %i[user_id send_lifecycle_notifications send_reminder_notification id _destroy], lieu_attributes: %i[name address latitude longitude id]) diff --git a/spec/features/agents/agent_can_update_rdv_spec.rb b/spec/features/agents/agent_can_update_rdv_spec.rb index 5c2fe3173e..7df2f45ab2 100644 --- a/spec/features/agents/agent_can_update_rdv_spec.rb +++ b/spec/features/agents/agent_can_update_rdv_spec.rb @@ -54,4 +54,20 @@ end end end + + context "mise à jour vers un motif d’une autre organisation", js: true do + let!(:other_motif) { create(:motif, name: "Dȋner aux chandelles", organisation: create(:organisation)) } + + it "empêche" do + visit edit_admin_organisation_rdv_path(organisation, rdv) + js = <<~JS + var selectElt = document.querySelector('select#rdv_motif_id'); + selectElt.options[selectElt.selectedIndex].value = "#{other_motif.id}"; + selectElt.removeAttribute('disabled'); + JS + page.execute_script(js) + click_button "Enregistrer" + expect(page).not_to have_content("Dȋner aux chandelles") + end + end end