Add a QWEN.md file to establish project context, preferences, and behavior guidelines for Qwen Code interactions with the aperonight Ruby on Rails project. This helps ensure consistent and appropriate responses tailored to this specific project setup. This change follows the convention of using a QWEN.md file to customize AI assistant behavior in development environments.
143 lines
4.0 KiB
Ruby
143 lines
4.0 KiB
Ruby
require "test_helper"
|
|
|
|
class PartyTest < ActiveSupport::TestCase
|
|
# Test that Party model exists
|
|
test "should be a class" do
|
|
assert_kind_of Class, Party
|
|
end
|
|
|
|
# Test validations
|
|
test "should not save party without name" do
|
|
party = Party.new(description: "Test party description")
|
|
assert_not party.save
|
|
end
|
|
|
|
test "should not save party without description" do
|
|
party = Party.new(name: "Test Party")
|
|
assert_not party.save
|
|
end
|
|
|
|
test "should not save party with name less than 3 characters" do
|
|
party = Party.new(name: "AB", description: "Valid description for the party")
|
|
assert_not party.save
|
|
end
|
|
|
|
test "should not save party with description less than 10 characters" do
|
|
party = Party.new(name: "Valid Party Name", description: "Too short")
|
|
assert_not party.save
|
|
end
|
|
|
|
test "should not save party without latitude" do
|
|
party = Party.new(
|
|
name: "Valid Party Name",
|
|
description: "Valid description for the party that is long enough",
|
|
longitude: 2.3522
|
|
)
|
|
assert_not party.save
|
|
end
|
|
|
|
test "should not save party without longitude" do
|
|
party = Party.new(
|
|
name: "Valid Party Name",
|
|
description: "Valid description for the party that is long enough",
|
|
latitude: 48.8566
|
|
)
|
|
assert_not party.save
|
|
end
|
|
|
|
test "should not save party with invalid latitude" do
|
|
party = Party.new(
|
|
name: "Valid Party Name",
|
|
description: "Valid description for the party that is long enough",
|
|
latitude: 95.0,
|
|
longitude: 2.3522,
|
|
venue_name: "Test Venue",
|
|
venue_address: "123 Test Street"
|
|
)
|
|
assert_not party.save
|
|
end
|
|
|
|
test "should not save party with invalid longitude" do
|
|
party = Party.new(
|
|
name: "Valid Party Name",
|
|
description: "Valid description for the party that is long enough",
|
|
latitude: 48.8566,
|
|
longitude: 190.0,
|
|
venue_name: "Test Venue",
|
|
venue_address: "123 Test Street"
|
|
)
|
|
assert_not party.save
|
|
end
|
|
|
|
test "should not save party without slug" do
|
|
party = Party.new(
|
|
name: "Valid Party Name",
|
|
description: "Valid description for the party that is long enough",
|
|
latitude: 48.8566,
|
|
longitude: 2.3522,
|
|
venue_name: "Test Venue",
|
|
venue_address: "123 Test Street"
|
|
)
|
|
assert_not party.save
|
|
end
|
|
|
|
test "should not save party with slug less than 3 characters" do
|
|
party = Party.new(
|
|
name: "Valid Party Name",
|
|
description: "Valid description for the party that is long enough",
|
|
latitude: 48.8566,
|
|
longitude: 2.3522,
|
|
venue_name: "Test Venue",
|
|
venue_address: "123 Test Street",
|
|
slug: "ab"
|
|
)
|
|
assert_not party.save
|
|
end
|
|
|
|
# Test enum states
|
|
test "should have valid states" do
|
|
assert_equal %w[draft published canceled sold_out], Party.states.keys
|
|
end
|
|
|
|
test "should default to draft state" do
|
|
party = Party.new(
|
|
name: "Valid Party Name",
|
|
description: "Valid description for the party that is long enough",
|
|
latitude: 48.8566,
|
|
longitude: 2.3522,
|
|
venue_name: "Test Venue",
|
|
venue_address: "123 Test Street"
|
|
)
|
|
assert_equal "draft", party.state
|
|
end
|
|
|
|
# Test associations
|
|
test "should belong to user" do
|
|
association = Party.reflect_on_association(:user)
|
|
assert_equal :belongs_to, association.macro
|
|
end
|
|
|
|
test "should have many ticket_types" do
|
|
association = Party.reflect_on_association(:ticket_types)
|
|
assert_equal :has_many, association.macro
|
|
end
|
|
|
|
test "should have many tickets through ticket_types" do
|
|
association = Party.reflect_on_association(:tickets)
|
|
assert_equal :has_many, association.macro
|
|
assert_equal :ticket_types, association.options[:through]
|
|
end
|
|
|
|
# Test scopes - using class methods directly to avoid DB connection issues
|
|
test "should respond to featured scope" do
|
|
assert_respond_to Party, :featured
|
|
end
|
|
|
|
test "should respond to published scope" do
|
|
assert_respond_to Party, :published
|
|
end
|
|
|
|
test "should respond to search_by_name scope" do
|
|
assert_respond_to Party, :search_by_name
|
|
end
|
|
end |