Skip to content
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
3 changes: 2 additions & 1 deletion app/controllers/contest_instances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def send_round_results

# Send an email for each entry
entries.each do |entry|
ResultsMailer.entry_evaluation_notification(entry, judging_round).deliver_later
mail = ResultsMailer.entry_evaluation_notification(entry, judging_round)
mail.deliver_later
email_count += 1
end

Expand Down
19 changes: 17 additions & 2 deletions spec/controllers/contest_instances_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,26 @@

# Configure ActiveJob to use inline adapter for testing
ActiveJob::Base.queue_adapter = :inline

# Mock the mailer to return a proper mail object
allow(ResultsMailer).to receive(:entry_evaluation_notification).and_wrap_original do |original_method, *args|
mail = original_method.call(*args)
allow(mail).to receive(:deliver_now) do
ActionMailer::Base.deliveries << mail
true
end
allow(mail).to receive(:deliver_later) do
ActionMailer::Base.deliveries << mail
true
end
mail
end
end

it 'sends emails for each entry' do
expect(ResultsMailer).to receive(:entry_evaluation_notification).with(entry1, judging_round).and_call_original
expect(ResultsMailer).to receive(:entry_evaluation_notification).with(entry2, judging_round).and_call_original
# Verify the mailer was called with the correct arguments
expect(ResultsMailer).to receive(:entry_evaluation_notification).with(entry1, judging_round)
expect(ResultsMailer).to receive(:entry_evaluation_notification).with(entry2, judging_round)

expect {
post :send_round_results, params: {
Expand Down