fix: Moving out from french for dev
This commit is contained in:
@@ -1,92 +0,0 @@
|
||||
require "test_helper"
|
||||
|
||||
class TicketPdfGeneratorCustomerNameTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
# Stub QR code generation to avoid dependency issues
|
||||
mock_qrcode = mock("qrcode")
|
||||
mock_qrcode.stubs(:modules).returns([])
|
||||
RQRCode::QRCode.stubs(:new).returns(mock_qrcode)
|
||||
|
||||
@user = User.create!(
|
||||
email: "test@example.com",
|
||||
password: "password123",
|
||||
password_confirmation: "password123"
|
||||
)
|
||||
|
||||
@event = Event.create!(
|
||||
name: "Test Event",
|
||||
slug: "test-event",
|
||||
description: "A valid description for the test event that is long enough",
|
||||
latitude: 48.8566,
|
||||
longitude: 2.3522,
|
||||
venue_name: "Test Venue",
|
||||
venue_address: "123 Test Street",
|
||||
user: @user,
|
||||
start_time: 1.week.from_now,
|
||||
end_time: 1.week.from_now + 3.hours,
|
||||
state: :published
|
||||
)
|
||||
|
||||
@ticket_type = TicketType.create!(
|
||||
name: "General Admission",
|
||||
description: "General admission tickets with full access to the event",
|
||||
price_cents: 2500,
|
||||
quantity: 100,
|
||||
sale_start_at: Time.current,
|
||||
sale_end_at: @event.start_time - 1.hour,
|
||||
requires_id: false,
|
||||
event: @event
|
||||
)
|
||||
|
||||
@order = Order.create!(
|
||||
user: @user,
|
||||
event: @event,
|
||||
status: "paid",
|
||||
total_amount_cents: 2500
|
||||
)
|
||||
|
||||
@ticket = Ticket.create!(
|
||||
order: @order,
|
||||
ticket_type: @ticket_type,
|
||||
status: "active",
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
qr_code: "test-qr-code-123"
|
||||
)
|
||||
end
|
||||
|
||||
test "should include customer name in PDF" do
|
||||
generator = TicketPdfGenerator.new(@ticket)
|
||||
pdf_string = generator.generate
|
||||
|
||||
assert_not_nil pdf_string
|
||||
assert_kind_of String, pdf_string
|
||||
assert pdf_string.length > 0
|
||||
|
||||
# Check if it starts with PDF header
|
||||
assert pdf_string.start_with?("%PDF")
|
||||
|
||||
# Check that the PDF is larger than expected (indicating content was added)
|
||||
# The customer name should make the PDF larger
|
||||
assert pdf_string.length > 1000, "PDF should be substantial in size"
|
||||
end
|
||||
|
||||
test "should generate valid PDF with customer name" do
|
||||
# Update ticket with name containing special characters
|
||||
@ticket.update!(first_name: "José", last_name: "Martínez")
|
||||
|
||||
generator = TicketPdfGenerator.new(@ticket)
|
||||
pdf_string = generator.generate
|
||||
|
||||
assert_not_nil pdf_string
|
||||
assert_kind_of String, pdf_string
|
||||
assert pdf_string.length > 0
|
||||
|
||||
# Check if it starts with PDF header
|
||||
assert pdf_string.start_with?("%PDF")
|
||||
|
||||
# Check that the PDF is valid
|
||||
assert pdf_string.length > 1000, "PDF should be substantial in size"
|
||||
assert pdf_string.end_with?("%%EOF\n"), "PDF should end with EOF marker"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user