Skip to content

Commit

Permalink
fix(bug): fix orientations update causing 500 (#2585)
Browse files Browse the repository at this point in the history
* fix(bug): fix orientations update causing 500
* non regression test
* apply Amines review
  • Loading branch information
Holist authored Jan 23, 2025
1 parent ffef538 commit a29bd9e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/users/orientations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Users
class OrientationsController < ApplicationController
before_action :set_user, :set_organisations, :set_agents, only: [:new, :edit, :create, :update]
before_action :set_orientations, only: [:create]
before_action :set_orientations, only: [:create, :update]
before_action :set_orientation, only: [:edit, :update, :destroy]
before_action :set_agent_ids_by_organisation_id, :set_orientation_types, only: [:new, :edit]

Expand Down Expand Up @@ -83,7 +83,7 @@ def reloaded_user_orientations
def save_orientation_and_redirect
@should_notify_organisation = new_organisation?
if save_orientation.success?
render :create
render :after_save
elsif save_orientation.shrinkeable_orientation.present?
turbo_stream_confirm_update_anterior_ends_at_modal
else
Expand Down
28 changes: 28 additions & 0 deletions spec/features/agent_can_add_user_orientations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,34 @@
expect(page).to have_content("non renseigné")
end

it "can update existing orientation and open organisation email notification if needed" do
orientation = create(:orientation,
user: user,
starts_at: "2023-07-03",
orientation_type: orientation_type_social,
organisation: organisation,
agent: organisation_agents.first)

visit organisation_user_path(organisation_id: organisation.id, id: user.id)
click_link("Parcours")

within("#orientation_#{orientation.id}") do
find("i.ri-pencil-fill").click
end

page.select orientation_type_pro.name, from: "orientation[orientation_type_id]"
page.select "Asso 26", from: "orientation_organisation_id"
page.select "Jean-Paul ROUVE", from: "orientation_agent_id"

click_button "Enregistrer"
expect(page).to have_no_content("Informer l’organisation par email")
click_button "Envoyer"

expect(page).to have_content("Professionnelle")
expect(page).to have_content("Asso 26")
expect(page).to have_content("Jean-Paul ROUVE")
end

it "open organisation email notification modal when adding an orientation to another organisation" do
visit organisation_user_path(organisation_id: organisation.id, id: user.id)

Expand Down

0 comments on commit a29bd9e

Please sign in to comment.