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:
kbe
2025-09-05 13:39:20 +02:00
parent ffd9d31c94
commit ed5ff4b8fd
10 changed files with 1126 additions and 25 deletions

29
test/fixtures/orders.yml vendored Normal file
View File

@@ -0,0 +1,29 @@
paid_order:
user: one
event: concert_event
status: paid
total_amount_cents: 2500
payment_attempts: 1
expires_at: <%= 1.hour.from_now %>
created_at: <%= 1.hour.ago %>
updated_at: <%= 1.hour.ago %>
draft_order:
user: one
event: concert_event
status: draft
total_amount_cents: 2500
payment_attempts: 0
expires_at: <%= 25.minutes.from_now %>
created_at: <%= 5.minutes.ago %>
updated_at: <%= 5.minutes.ago %>
expired_order:
user: two
event: concert_event
status: expired
total_amount_cents: 2500
payment_attempts: 1
expires_at: <%= 1.hour.ago %>
created_at: <%= 2.hours.ago %>
updated_at: <%= 1.hour.ago %>