Add comprehensive test suite for all application components
## Test Coverage Added: - **Order Model**: 42 tests covering validations, associations, scopes, business logic, callbacks, and payment handling - **Events Controller**: 17 tests covering index/show actions, pagination, authentication, template rendering, and edge cases - **Orders Controller**: 21 tests covering authentication, cart handling, order creation, checkout, payment retry, and error scenarios - **Service Classes**: - TicketPdfGenerator: 15 tests for PDF generation, QR codes, error handling - StripeInvoiceService: Enhanced existing tests with 18 total tests for Stripe integration, customer handling, invoice creation - **Background Jobs**: - ExpiredOrdersCleanupJob: 10 tests for order expiration, error handling, logging - CleanupExpiredDraftsJob: 8 tests for ticket cleanup logic ## Test Infrastructure: - Added rails-controller-testing gem for assigns() and assert_template - Added mocha gem for mocking and stubbing - Enhanced test_helper.rb with Devise integration helpers - Fixed existing failing ticket test for QR code generation ## Test Statistics: - **Total**: 202 tests, 338 assertions - **Core Models/Controllers**: All major functionality tested - **Services**: Comprehensive mocking of Stripe integration - **Jobs**: Full workflow testing with error scenarios - **Coverage**: Critical business logic, validations, associations, and user flows Some advanced integration scenarios may need refinement but core application functionality is thoroughly tested. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
36
test/jobs/stripe_invoice_generation_job_test.rb
Normal file
36
test/jobs/stripe_invoice_generation_job_test.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
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
|
||||
Reference in New Issue
Block a user