Skip to content

Commit

Permalink
Bug/2816/confirmation emails (#81)
Browse files Browse the repository at this point in the history
* Adjust user interested in email to also include managers

* Add spec
  • Loading branch information
njaeggi authored Sep 12, 2024
1 parent f96fa7a commit fac5e47
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/youth/event/participations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ module Youth::Event::ParticipationsController
alias_method_chain :return_path, :managed
alias_method_chain :after_destroy_path, :managed
alias_method_chain :set_success_notice, :managed

def current_user_interested_in_mail?
# send email to kind and verwalter
current_user.and_manageds.map(&:id).include? entry.person_id
end
end

def cancel
Expand Down
19 changes: 19 additions & 0 deletions spec/controllers/event/participations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 <i>#{user}</i> in <i>Eventus</i> 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,
Expand Down

0 comments on commit fac5e47

Please sign in to comment.