Skip to content

Commit 0a0f7fa

Browse files
Send emails for required participation approvals (#449)
* exchange after_create with after_commit * fix: remove breakpoint * Add spec --------- Co-authored-by: Andreas Maierhofer <maierhofer@puzzle.ch>
1 parent 5717a4d commit 0a0f7fa

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

app/models/pbs/event/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Pbs::Event::Application
1111

1212
has_many :approvals, dependent: :destroy
1313

14-
after_create :initialize_approval
14+
after_commit :initialize_approval, on: :create
1515
end
1616

1717
def next_open_approval

spec/models/event/participation_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@
6363
expect(participation.approvers).to have(2).items
6464
expect(participation.approvers).to include(people(:bulei), people(:al_schekka))
6565
end
66+
67+
it "enqueues approval request job with participation" do
68+
event.update!(requires_approval_abteilung: true)
69+
participation = Fabricate(:pbs_participation,
70+
event: event,
71+
application: Event::Application.new(priority_1: event), participant: people(:child))
72+
job = Delayed::Job.last.payload_object
73+
expect(job).to be_a(Event::ApprovalRequestJob)
74+
expect(job.parameters[:participation_id]).to eq participation.id
75+
end
6676
end
6777

6878
context "#j_s_data_sharing_accepted" do

0 commit comments

Comments
 (0)