feat: Implement event image upload system for promoters
- Add Active Storage migrations for file attachments - Update Event model to handle image uploads with validation - Replace image URL fields with file upload in forms - Add client-side image preview with validation - Update all views to display uploaded images properly - Fix JSON serialization to prevent stack overflow in API - Add custom image validation methods for format and size - Include image processing variants for different display sizes - Fix promotion code test infrastructure and Stripe configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
74
debug_promotion_test.rb
Executable file
74
debug_promotion_test.rb
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Debug script to understand the test failure
|
||||
require_relative './config/environment'
|
||||
|
||||
# Load test data
|
||||
user = User.find_by(email: 'user1@example.com')
|
||||
event = Event.find_by(name: 'Summer Concert')
|
||||
|
||||
puts "User: #{user.inspect}"
|
||||
puts "Event: #{event.inspect}"
|
||||
|
||||
# Create a new order for the test
|
||||
order = user.orders.create!(event: event, status: "draft", expires_at: 15.minutes.from_now, total_amount_cents: 2000)
|
||||
puts "Order: #{order.inspect}"
|
||||
|
||||
# Create ticket type and ticket
|
||||
ticket_type = TicketType.create!(
|
||||
name: "Test Ticket Type",
|
||||
description: "A valid description for the ticket type that is long enough",
|
||||
price_cents: 2000,
|
||||
quantity: 10,
|
||||
sale_start_at: Time.current,
|
||||
sale_end_at: Time.current + 1.day,
|
||||
requires_id: false,
|
||||
event: event
|
||||
)
|
||||
|
||||
ticket = Ticket.create!(
|
||||
order: order,
|
||||
ticket_type: ticket_type,
|
||||
status: "draft",
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
price_cents: 2000
|
||||
)
|
||||
|
||||
puts "Ticket: #{ticket.inspect}"
|
||||
puts "Ticket valid?: #{ticket.valid?}"
|
||||
puts "Order tickets count: #{order.tickets.count}"
|
||||
|
||||
# Recalculate the order total
|
||||
order.calculate_total!
|
||||
puts "Order total: #{order.total_amount_cents}"
|
||||
|
||||
# Create a unique promotion code
|
||||
unique_code = "TESTDISCOUNT_#{SecureRandom.hex(4)}"
|
||||
puts "Creating promotion code with code: #{unique_code}"
|
||||
|
||||
promotion_code = PromotionCode.create(
|
||||
code: unique_code,
|
||||
discount_amount_cents: 500,
|
||||
expires_at: 1.month.from_now,
|
||||
active: true,
|
||||
user: user,
|
||||
event: event
|
||||
)
|
||||
|
||||
puts "Promotion code: #{promotion_code.inspect}"
|
||||
puts "Promotion code valid?: #{promotion_code.valid?}"
|
||||
|
||||
# Check if order already has promotion codes
|
||||
puts "Order promotion codes before: #{order.promotion_codes.count}"
|
||||
|
||||
# Try to apply the promotion code
|
||||
begin
|
||||
order.promotion_codes << promotion_code
|
||||
puts "Successfully added promotion code to order"
|
||||
rescue => e
|
||||
puts "Error adding promotion code: #{e.message}"
|
||||
puts e.backtrace.first(5)
|
||||
end
|
||||
|
||||
puts "Order promotion codes after: #{order.promotion_codes.count}"
|
||||
Reference in New Issue
Block a user