Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useful error message in application market controller (#367) #379

Merged
merged 4 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Hitobito PBS Changelog

## unreleased

* Das Hinzufügen eines Teilnehmenden via nationale Warteliste, prüft neu korrekt auf die J+S Datenfreigabe und gibt eine sprechende Fehlermeldung (hitobito_pbs#367)

## Version 2.2

* LKB/Coach in Event-Resource der API aufgenommen (hitobito_pbs#325)
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/pbs/event/application_market_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ module Pbs::Event::ApplicationMarketController
included do
alias_method_chain :put_on_waiting_list, :setter
alias_method_chain :remove_from_waiting_list, :setter

def assigner_add_participant
if event.j_s_data_sharing_acceptance_required? && participation.j_s_data_sharing_accepted_at.nil?
render "j_s_data_sharing_not_accepted_error"
else
assigner.add_participant
end
end
end

def remove_from_waiting_list_with_setter
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-# Copyright (c) 2012-2025, Jungwacht Blauring Schweiz. This file is part of
-# hitobito and licensed under the Affero General Public License version 3
-# or later. See the COPYING file at the top-level directory or at
-# https://github.com/hitobito/hitobito.
alert('#{t(:"event.application_market.j_s_data_sharing_not_accepted")}');
2 changes: 2 additions & 0 deletions config/locales/views.pbs.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ de:
coach_title: 8. Coach

event:
application_market:
j_s_data_sharing_not_accepted: Diese Person hat bei der Anmledung für den anderen Kurs die J+S Datenweitergabe nicht akzeptiert, dieser ist für diesen Kurs Pflicht, die Anmeldung ist daher leider nicht möglich.
attendances:
index:
info: Erfasse hier die Anzahl BSV-Tage für jede Person.
Expand Down
35 changes: 35 additions & 0 deletions spec/features/application_market_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) 2019-2025 Pfadibewegung Schweiz. This file is part of
# hitobito_pbs and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_pbs.

require "spec_helper"

describe Event::ApplicationMarketController, js: true do
let(:event) { Fabricate(:course, kind: event_kinds(:lpk)) }

let(:group) { event.groups.first }

let!(:appl_waiting) do
Fabricate(:event_participation,
application: Fabricate(:event_application, waiting_list: true, priority_1: event, priority_2: nil),
event: Fabricate(:course, kind: event_kinds(:lpk)),
person: people(:al_schekka))
end

it "displays custom error alert when person from national waiting list did not accept J&S data sharing" do
allow_any_instance_of(Event).to receive(:j_s_data_sharing_acceptance_required?).and_return(true)
sign_in(people(:bulei))
visit group_event_application_market_index_path(group_id: group.id, event_id: event.id)
find("#waiting_list").set(true)
click_button("Aktualisieren")
expect(page).to have_text("Schekka AL")
find(".fa-arrow-left").click
sleep(3)
alert_text = page.driver.browser.switch_to.alert.text
expect(alert_text).to include(
"Diese Person hat bei der Anmledung für den anderen Kurs die J+S Datenweitergabe nicht akzeptiert, dieser ist für diesen Kurs Pflicht, " \
"die Anmeldung ist daher leider nicht möglich."
)
end
end
Loading