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:
@@ -1,4 +1,5 @@
|
||||
require "test_helper"
|
||||
require "securerandom"
|
||||
|
||||
class OrdersControllerPromotionTest < ActionDispatch::IntegrationTest
|
||||
include Devise::Test::IntegrationHelpers
|
||||
@@ -7,7 +8,8 @@ class OrdersControllerPromotionTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:one)
|
||||
@event = events(:concert_event)
|
||||
@order = orders(:draft_order)
|
||||
# Create a new order for the test to ensure proper associations
|
||||
@order = @user.orders.create!(event: @event, status: "draft", expires_at: 15.minutes.from_now, total_amount_cents: 2000)
|
||||
sign_in @user
|
||||
end
|
||||
|
||||
@@ -25,19 +27,27 @@ class OrdersControllerPromotionTest < ActionDispatch::IntegrationTest
|
||||
event: @event
|
||||
)
|
||||
|
||||
Ticket.create!(
|
||||
ticket = Ticket.create!(
|
||||
order: @order,
|
||||
ticket_type: ticket_type,
|
||||
status: "draft",
|
||||
first_name: "John",
|
||||
last_name: "Doe"
|
||||
last_name: "Doe",
|
||||
price_cents: 2000
|
||||
)
|
||||
|
||||
# Debug the ticket creation
|
||||
puts "Ticket saved: #{ticket.persisted?}"
|
||||
puts "Ticket errors: #{ticket.errors.full_messages}" unless ticket.valid?
|
||||
puts "Order tickets count: #{@order.tickets.count}"
|
||||
|
||||
# Recalculate the order total
|
||||
@order.calculate_total!
|
||||
|
||||
# Use a unique code for each test run
|
||||
unique_code = "TESTDISCOUNT_#{SecureRandom.hex(4)}"
|
||||
promotion_code = PromotionCode.create(
|
||||
code: "TESTDISCOUNT",
|
||||
code: unique_code,
|
||||
discount_amount_cents: 500, # €5.00
|
||||
expires_at: 1.month.from_now,
|
||||
active: true,
|
||||
@@ -45,7 +55,9 @@ class OrdersControllerPromotionTest < ActionDispatch::IntegrationTest
|
||||
event: @event
|
||||
)
|
||||
|
||||
get checkout_order_path(@order), params: { promotion_code: "TESTDISCOUNT" }
|
||||
get checkout_order_path(@order), params: { promotion_code: unique_code }
|
||||
puts "Response status: #{response.status}"
|
||||
puts "Response body: #{response.body}" if response.status != 200
|
||||
assert_response :success
|
||||
assert_not_nil flash.now[:notice]
|
||||
assert_match /Code promotionnel appliqué: TESTDISCOUNT/, flash.now[:notice]
|
||||
|
||||
Reference in New Issue
Block a user