- Implement comprehensive email notification system for ticket purchases and event reminders - Add event reminder job with configurable scheduling - Enhance ticket mailer with QR code generation and proper formatting - Update order model with email delivery tracking - Add comprehensive test coverage for all email functionality - Configure proper mailer settings and disable annotations - Update backlog to reflect completed email features 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
39 lines
1.2 KiB
Ruby
39 lines
1.2 KiB
Ruby
require "test_helper"
|
|
|
|
class OrderEmailTest < ActiveSupport::TestCase
|
|
def setup
|
|
@order = orders(:draft_order)
|
|
end
|
|
|
|
test "sends purchase confirmation email when order is marked as paid" do
|
|
# Mock the mailer to capture the call
|
|
TicketMailer.expects(:purchase_confirmation_order).with(@order).returns(stub(deliver_now: true))
|
|
|
|
@order.mark_as_paid!
|
|
|
|
assert_equal "paid", @order.status
|
|
end
|
|
|
|
test "activates all tickets when order is marked as paid" do
|
|
@order.tickets.update_all(status: "reserved")
|
|
|
|
# Mock the mailer to avoid actual email sending
|
|
TicketMailer.stubs(:purchase_confirmation_order).returns(stub(deliver_now: true))
|
|
|
|
@order.mark_as_paid!
|
|
|
|
assert @order.tickets.all? { |ticket| ticket.status == "active" }
|
|
end
|
|
|
|
test "email sending failure does not prevent order completion" do
|
|
# Mock mailer to raise an error
|
|
TicketMailer.stubs(:purchase_confirmation_order).raises(StandardError.new("Email error"))
|
|
|
|
# Should not raise error - email failure is logged but doesn't fail the payment
|
|
@order.mark_as_paid!
|
|
|
|
# Order should still be marked as paid even if email fails
|
|
assert_equal "paid", @order.reload.status
|
|
end
|
|
end
|