Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Holist committed Oct 8, 2024
1 parent 0cad665 commit d7984df
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def sync_user_with_rdv_solidarites(user)
return if sync.success?

respond_to do |format|
format.turbo_stream { flash.now[:error] = "L'usager n'est plus lié à rdv-solidarités: #{sync.errors.join(', ')}" }
format.json { render json: { errors: sync.errors.join(", ") }, status: :unprocessable_entity }
format.turbo_stream do
flash.now[:error] = "L'usager n'est plus lié à rdv-solidarités: #{sync.errors.map(&:to_s)}"
end
format.json { render json: { errors: sync.errors.map(&:to_s) }, status: :unprocessable_entity }
end
end
end
2 changes: 1 addition & 1 deletion app/jobs/application_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def call_service!(service_class, **kwargs)
raise(
ApplicationJob::FailedServiceError,
"Calling service #{service_class} failed in #{self.class}:\n" \
"Errors: #{service_result.errors.join(', ')}"
"Errors: #{service_result.errors.map(&:to_s)}"
)
end
end
2 changes: 2 additions & 0 deletions app/services/base_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def call

private

# On peut ajouter des TemplatedErrorPresenter à errors tout en gardant la possibilité d'ajouter des
# strings simples dans le tableau errors. TemplatedErrorPresenter répond à to_s avec le message
def add_custom_error(message:, template_name:, locals: {})
result.errors << TemplatedErrorPresenter.new(message: message, template_name: template_name, locals: locals)
end
Expand Down
1 change: 1 addition & 0 deletions spec/controllers/users_organisations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@

expect(response).to have_http_status(:see_other)
expect(response.location).to eq(department_user_url(department, user))
expect(flash[:error]).to include("L'usager n'est plus lié à rdv-solidarités: [\"Something went wrong\"]")
end
end
end
Expand Down

0 comments on commit d7984df

Please sign in to comment.