refactor(events): replace parties concept with events throughout the application

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

This commit refactors the entire application to replace the 'parties' concept with 'events'. All controllers, models, views, and related files have been updated to reflect this change. The parties table has been replaced with an events table, and all related functionality has been updated accordingly.
This commit is contained in:
Kevin BATAILLE
2025-08-28 13:20:51 +02:00
parent 2f80fe8321
commit 30f3ecc6ad
218 changed files with 864 additions and 787 deletions

163
test/models/event_test.rb Executable file
View File

@@ -0,0 +1,163 @@
require "test_helper"
class EventTest < ActiveSupport::TestCase
# Test that Event model exists
test "should be a class" do
assert_kind_of Class, Event
end
# Test validations
test "should not save event without name" do
event = Event.new(description: "Test event description")
assert_not event.save
end
test "should not save event without description" do
event = Event.new(name: "Test Event")
assert_not event.save
end
test "should not save event with name less than 3 characters" do
event = Event.new(name: "AB", description: "Valid description for the event")
assert_not event.save
end
test "should not save event with description less than 10 characters" do
event = Event.new(name: "Valid Event Name", description: "Too short")
assert_not event.save
end
test "should not save event without latitude" do
event = Event.new(
name: "Valid Event Name",
description: "Valid description for the event that is long enough",
longitude: 2.3522
)
assert_not event.save
end
test "should not save event without longitude" do
event = Event.new(
name: "Valid Event Name",
description: "Valid description for the event that is long enough",
latitude: 48.8566
)
assert_not event.save
end
test "should not save event with invalid latitude" do
event = Event.new(
name: "Valid Event Name",
description: "Valid description for the event that is long enough",
latitude: 95.0,
longitude: 2.3522,
venue_name: "Test Venue",
venue_address: "123 Test Street"
)
assert_not event.save
end
test "should not save event with invalid longitude" do
event = Event.new(
name: "Valid Event Name",
description: "Valid description for the event that is long enough",
latitude: 48.8566,
longitude: 190.0,
venue_name: "Test Venue",
venue_address: "123 Test Street"
)
assert_not event.save
end
test "should not save event without slug" do
event = Event.new(
name: "Valid Event Name",
description: "Valid description for the event that is long enough",
latitude: 48.8566,
longitude: 2.3522,
venue_name: "Test Venue",
venue_address: "123 Test Street"
)
assert_not event.save
end
test "should not save event with slug less than 3 characters" do
event = Event.new(
name: "Valid Event Name",
description: "Valid description for the event that is long enough",
latitude: 48.8566,
longitude: 2.3522,
venue_name: "Test Venue",
venue_address: "123 Test Street",
slug: "ab"
)
assert_not event.save
end
test "should save valid event" do
user = User.create!(
email: "test@example.com",
password: "password123",
password_confirmation: "password123"
)
event = Event.new(
name: "Valid Event Name",
slug: "valid-event-name",
description: "Valid description for the event that is long enough",
latitude: 48.8566,
longitude: 2.3522,
venue_name: "Test Venue",
venue_address: "123 Test Street",
user: user,
)
assert event.save
end
# Test enum states
test "should have valid states" do
assert_equal %w[draft published canceled sold_out], Event.states.keys
end
test "should default to draft state" do
event = Event.new(
name: "Valid Event Name",
description: "Valid description for the event that is long enough",
latitude: 48.8566,
longitude: 2.3522,
venue_name: "Test Venue",
venue_address: "123 Test Street"
)
assert_equal "draft", event.state
end
# Test associations
test "should belong to user" do
association = Event.reflect_on_association(:user)
assert_equal :belongs_to, association.macro
end
test "should have many ticket_types" do
association = Event.reflect_on_association(:ticket_types)
assert_equal :has_many, association.macro
end
test "should have many tickets through ticket_types" do
association = Event.reflect_on_association(:tickets)
assert_equal :has_many, association.macro
assert_equal :ticket_types, association.options[:through]
end
# Test scopes
test "should respond to featured scope" do
assert_respond_to Event, :featured
end
test "should respond to published scope" do
assert_respond_to Event, :published
end
test "should respond to search_by_name scope" do
assert_respond_to Event, :search_by_name
end
end