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:
14
test/fixtures/events.yml
vendored
14
test/fixtures/events.yml
vendored
@@ -1,17 +1,19 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: Summer Event
|
||||
slug: summer-event
|
||||
description: A great summer event with music and drinks
|
||||
concert_event:
|
||||
name: Summer Concert
|
||||
slug: summer-concert
|
||||
description: A great summer concert with live music and drinks
|
||||
state: published
|
||||
venue_name: Beach Club
|
||||
venue_address: 123 Ocean Drive
|
||||
latitude: 40.7128
|
||||
longitude: -74.0060
|
||||
start_time: <%= 1.week.from_now %>
|
||||
end_time: <%= 1.week.from_now + 4.hours %>
|
||||
user: one
|
||||
|
||||
two:
|
||||
winter_gala:
|
||||
name: Winter Gala
|
||||
slug: winter-gala
|
||||
description: An elegant winter gala for the holidays
|
||||
@@ -20,4 +22,6 @@ two:
|
||||
venue_address: 456 Park Avenue
|
||||
latitude: 40.7589
|
||||
longitude: -73.9851
|
||||
start_time: <%= 2.weeks.from_now %>
|
||||
end_time: <%= 2.weeks.from_now + 6.hours %>
|
||||
user: two
|
||||
|
||||
29
test/fixtures/orders.yml
vendored
Normal file
29
test/fixtures/orders.yml
vendored
Normal 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 %>
|
||||
8
test/fixtures/ticket_types.yml
vendored
8
test/fixtures/ticket_types.yml
vendored
@@ -1,21 +1,21 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
standard:
|
||||
name: General Admission
|
||||
description: General admission ticket for the event
|
||||
price_cents: 1000
|
||||
quantity: 100
|
||||
sale_start_at: <%= 1.day.ago %>
|
||||
sale_end_at: <%= 1.day.from_now %>
|
||||
event: one
|
||||
event: concert_event
|
||||
# minimum_age: 18
|
||||
|
||||
two:
|
||||
vip:
|
||||
name: VIP Access
|
||||
description: VIP access ticket with special privileges
|
||||
price_cents: 2500
|
||||
quantity: 50
|
||||
sale_start_at: <%= 1.day.ago %>
|
||||
sale_end_at: <%= 1.day.from_now %>
|
||||
event: two
|
||||
event: concert_event
|
||||
# minimum_age: 18
|
||||
|
||||
21
test/fixtures/tickets.yml
vendored
21
test/fixtures/tickets.yml
vendored
@@ -2,14 +2,27 @@
|
||||
|
||||
one:
|
||||
qr_code: QR001
|
||||
user: one
|
||||
ticket_type: one
|
||||
order: paid_order
|
||||
ticket_type: standard
|
||||
first_name: John
|
||||
last_name: Doe
|
||||
price_cents: 1000
|
||||
status: active
|
||||
|
||||
two:
|
||||
qr_code: QR002
|
||||
user: two
|
||||
ticket_type: two
|
||||
order: paid_order
|
||||
ticket_type: vip
|
||||
first_name: Jane
|
||||
last_name: Smith
|
||||
price_cents: 1500
|
||||
status: active
|
||||
|
||||
draft_ticket:
|
||||
qr_code: QR003
|
||||
order: draft_order
|
||||
ticket_type: standard
|
||||
first_name: Bob
|
||||
last_name: Wilson
|
||||
price_cents: 1000
|
||||
status: draft
|
||||
|
||||
Reference in New Issue
Block a user