Add duplication options with JavaScript modal and conditional ticket type cloning
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -56,7 +56,7 @@ class Promoter::EventsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
# Duplicate the event
|
||||
assert_difference('Event.count', 1) do
|
||||
post duplicate_promoter_event_path(@event)
|
||||
post duplicate_promoter_event_path(@event), params: { clone_ticket_types: "true" }
|
||||
end
|
||||
|
||||
# Check that the new event was created
|
||||
@@ -76,5 +76,53 @@ class Promoter::EventsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_equal "VIP Ticket", new_event.ticket_types.find_by(name: "VIP Ticket").name
|
||||
end
|
||||
|
||||
test "should duplicate an event without ticket types" do
|
||||
sign_in @promoter
|
||||
|
||||
# Create ticket types for the event
|
||||
ticket_type1 = TicketType.create!(
|
||||
name: "Standard Ticket",
|
||||
description: "A standard ticket for the event with all the basic access",
|
||||
price_cents: 2000,
|
||||
quantity: 100,
|
||||
sale_start_at: 1.day.ago,
|
||||
sale_end_at: @event.start_time - 1.hour,
|
||||
event: @event
|
||||
)
|
||||
|
||||
ticket_type2 = TicketType.create!(
|
||||
name: "VIP Ticket",
|
||||
description: "A VIP ticket for the event with special access",
|
||||
price_cents: 5000,
|
||||
quantity: 50,
|
||||
sale_start_at: 1.day.ago,
|
||||
sale_end_at: @event.start_time - 1.hour,
|
||||
event: @event
|
||||
)
|
||||
|
||||
# Verify that ticket types were created successfully
|
||||
assert ticket_type1.valid?
|
||||
assert ticket_type2.valid?
|
||||
|
||||
# Duplicate the event without ticket types
|
||||
assert_difference('Event.count', 1) do
|
||||
post duplicate_promoter_event_path(@event), params: { clone_ticket_types: "false" }
|
||||
end
|
||||
|
||||
# Check that the new event was created
|
||||
assert_redirected_to edit_promoter_event_path(Event.last)
|
||||
assert_equal "Événement dupliqué avec succès! Vous pouvez maintenant modifier les détails de l'événement copié.", flash[:notice]
|
||||
|
||||
# Check that the new event has the correct attributes
|
||||
new_event = Event.last
|
||||
assert_equal "Copie de #{@event.name}", new_event.name
|
||||
assert_equal "draft", new_event.state
|
||||
assert_equal @event.venue_name, new_event.venue_name
|
||||
assert_equal @event.venue_address, new_event.venue_address
|
||||
|
||||
# Check that ticket types were NOT duplicated
|
||||
assert_equal 0, new_event.ticket_types.count
|
||||
end
|
||||
|
||||
# Add tests for new, create, etc. as needed
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user