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:
kbe
2025-09-30 00:41:03 +02:00
parent be7b3d5c18
commit 6be8b95ed3
22 changed files with 450 additions and 36 deletions

View File

@@ -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]

View File

@@ -5,6 +5,7 @@ one:
encrypted_password: <%= Devise::Encryptor.digest(User, 'password123') %>
last_name: Trump
first_name: Donald
is_professionnal: true
onboarding_completed: true
two:

View File

@@ -19,6 +19,14 @@ module ActiveSupport
# Add more helper methods to be used by all tests here...
# Mock Stripe for tests
setup do
# Mock Stripe checkout session creation
Stripe::Checkout::Session.stubs(:create).returns(
Struct.new(:id, :url).new("cs_test_session", "https://checkout.stripe.com/test")
)
end
# Helper to create users with completed onboarding by default for tests
def create_test_user(attributes = {})
User.create!({