From 0b6a8b9b9bd0ffaa21094e57eb1305d5f7315633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20J=C3=A4ggi?= Date: Tue, 10 Sep 2024 16:43:05 +0200 Subject: [PATCH] Add spec --- .../event/participations_controller_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/controllers/event/participations_controller_spec.rb b/spec/controllers/event/participations_controller_spec.rb index da5f1a0..f1fcd29 100644 --- a/spec/controllers/event/participations_controller_spec.rb +++ b/spec/controllers/event/participations_controller_spec.rb @@ -36,6 +36,25 @@ end context 'POST#create' do + let(:pending_dj_handlers) { Delayed::Job.all.pluck(:handler) } + let(:user) { people(:bottom_member) } + + it "sends confirmation mail when manager registers managed" do + PeopleManager.create!(manager_id: people(:top_leader).id, managed_id: user.id) + course.update!(waiting_list: false, maximum_participants: 2, participant_count: 1, automatic_assignment: true) + + expect do + post :create, params: {group_id: group.id, event_id: course.id, event_participation: {person_id: user.id}} + expect(assigns(:participation)).to be_valid + end.to change { Delayed::Job.count } + + expect(pending_dj_handlers).to be_one { |h| h =~ /Event::ParticipationNotificationJob/ } + expect(pending_dj_handlers).to be_one { |h| h =~ /Event::ParticipationConfirmationJob/ } + + expect(flash[:notice]) + .to include "Teilnahme von #{user} in Eventus wurde erfolgreich erstellt. Bitte überprüfe die Kontaktdaten und passe diese gegebenenfalls an." + expect(flash[:warning]).to be_nil + end it 'sets participation state to applied' do post :create,