require "test_helper" class StripeInvoiceGenerationJobTest < ActiveJob::TestCase setup do @paid_order = orders(:paid_order) end test "should schedule job" do assert_enqueued_with(job: StripeInvoiceGenerationJob, args: [ @paid_order.id ]) do StripeInvoiceGenerationJob.perform_later(@paid_order.id) end end test "should not create invoice for unpaid order" do draft_order = orders(:draft_order) # Should not raise error, just log warning and return assert_nothing_raised do StripeInvoiceGenerationJob.perform_now(draft_order.id) end end test "should handle non-existent order gracefully" do non_existent_id = 99999 # Should not raise error, just log error and return assert_nothing_raised do StripeInvoiceGenerationJob.perform_now(non_existent_id) end end test "should be configured with correct queue" do job = StripeInvoiceGenerationJob.new assert_equal :default, job.queue_name.to_sym end end