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

0
test/application_system_test_case.rb Normal file → Executable file
View File

0
test/controllers/.keep Normal file → Executable file
View File

0
test/controllers/pages_controller_test.rb Normal file → Executable file
View File

6
test/fixtures/parties.yml → test/fixtures/events.yml vendored Normal file → Executable file
View File

@@ -1,9 +1,9 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: Summer Party
slug: summer-party
description: A great summer party with music and drinks
name: Summer Event
slug: summer-event
description: A great summer event with music and drinks
state: published
venue_name: Beach Club
venue_address: 123 Ocean Drive

0
test/fixtures/files/.keep vendored Normal file → Executable file
View File

4
test/fixtures/ticket_types.yml vendored Normal file → Executable file
View File

@@ -7,7 +7,7 @@ one:
quantity: 100
sale_start_at: <%= 1.day.ago %>
sale_end_at: <%= 1.day.from_now %>
party: one
event: one
two:
name: VIP Access
@@ -16,4 +16,4 @@ two:
quantity: 50
sale_start_at: <%= 1.day.ago %>
sale_end_at: <%= 1.day.from_now %>
party: two
event: two

0
test/fixtures/tickets.yml vendored Normal file → Executable file
View File

0
test/fixtures/users.yml vendored Normal file → Executable file
View File

0
test/helpers/.keep Normal file → Executable file
View File

0
test/integration/.keep Normal file → Executable file
View File

0
test/mailers/.keep Normal file → Executable file
View File

0
test/models/.keep Normal file → Executable file
View File

0
test/models/application_record_test.rb Normal file → Executable file
View File

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

View File

@@ -1,163 +0,0 @@
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 "should save valid party" do
user = User.create!(
email: "test@example.com",
password: "password123",
password_confirmation: "password123"
)
party = Party.new(
name: "Valid Party Name",
slug: "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",
user: user,
)
assert 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
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

54
test/models/ticket_test.rb Normal file → Executable file
View File

@@ -14,10 +14,10 @@ class TicketTest < ActiveSupport::TestCase
password_confirmation: "password123"
)
party = Party.create!(
name: "Valid Party Name",
slug: "valid-party-name",
description: "Valid description for the party that is long enough",
event = Event.create!(
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",
@@ -33,7 +33,7 @@ class TicketTest < ActiveSupport::TestCase
sale_start_at: Time.current,
sale_end_at: Time.current + 1.day,
requires_id: false,
party: party
event: event
)
ticket = Ticket.new(user: user, ticket_type: ticket_type)
@@ -87,8 +87,8 @@ class TicketTest < ActiveSupport::TestCase
assert_equal :belongs_to, association.macro
end
test "should have one party through ticket_type" do
association = Ticket.reflect_on_association(:party)
test "should have one event through ticket_type" do
association = Ticket.reflect_on_association(:event)
assert_equal :has_one, association.macro
assert_equal :ticket_type, association.options[:through]
end
@@ -108,10 +108,10 @@ class TicketTest < ActiveSupport::TestCase
password_confirmation: "password123"
)
party = Party.create!(
name: "Valid Party Name",
slug: "valid-party-name",
description: "Valid description for the party that is long enough",
event = Event.create!(
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",
@@ -127,7 +127,7 @@ class TicketTest < ActiveSupport::TestCase
sale_start_at: Time.current,
sale_end_at: Time.current + 1.day,
requires_id: false,
party: party
event: event
)
ticket = Ticket.new(
@@ -147,10 +147,10 @@ class TicketTest < ActiveSupport::TestCase
password_confirmation: "password123"
)
party = Party.create!(
name: "Valid Party Name",
slug: "valid-party-name",
description: "Valid description for the party that is long enough",
event = Event.create!(
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",
@@ -166,7 +166,7 @@ class TicketTest < ActiveSupport::TestCase
sale_start_at: Time.current,
sale_end_at: Time.current + 1.day,
requires_id: false,
party: party
event: event
)
ticket = Ticket.new(
@@ -185,10 +185,10 @@ class TicketTest < ActiveSupport::TestCase
password_confirmation: "password123"
)
party = Party.create!(
name: "Valid Party Name",
slug: "valid-party-name",
description: "Valid description for the party that is long enough",
event = Event.create!(
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",
@@ -204,7 +204,7 @@ class TicketTest < ActiveSupport::TestCase
sale_start_at: Time.current,
sale_end_at: Time.current + 1.day,
requires_id: false,
party: party
event: event
)
ticket = Ticket.new(
@@ -223,10 +223,10 @@ class TicketTest < ActiveSupport::TestCase
password_confirmation: "password123"
)
party = Party.create!(
name: "Valid Party Name",
slug: "valid-party-name",
description: "Valid description for the party that is long enough",
event = Event.create!(
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",
@@ -242,7 +242,7 @@ class TicketTest < ActiveSupport::TestCase
sale_start_at: Time.current,
sale_end_at: Time.current + 1.day,
requires_id: false,
party: party
event: event
)
ticket = Ticket.new(

44
test/models/ticket_type_test.rb Normal file → Executable file
View File

@@ -88,10 +88,10 @@ class TicketTypeTest < ActiveSupport::TestCase
password_confirmation: "password123"
)
party = Party.create!(
name: "Valid Party Name",
slug: "valid-party-name",
description: "Valid description for the party that is long enough",
event = Event.create!(
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",
@@ -107,14 +107,14 @@ class TicketTypeTest < ActiveSupport::TestCase
sale_start_at: Time.current,
sale_end_at: Time.current + 1.day,
requires_id: false,
party: party
event: event
)
assert ticket_type.save
end
# Test associations
test "should belong to party" do
association = TicketType.reflect_on_association(:party)
test "should belong to event" do
association = TicketType.reflect_on_association(:event)
assert_equal :belongs_to, association.macro
end
@@ -131,10 +131,10 @@ class TicketTypeTest < ActiveSupport::TestCase
password_confirmation: "password123"
)
party = Party.create!(
name: "Valid Party Name",
slug: "valid-party-name",
description: "Valid description for the party that is long enough",
event = Event.create!(
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",
@@ -150,7 +150,7 @@ class TicketTypeTest < ActiveSupport::TestCase
sale_start_at: Time.current,
sale_end_at: Time.current + 1.day,
requires_id: true,
party: party
event: event
)
assert ticket_type.save
end
@@ -162,10 +162,10 @@ class TicketTypeTest < ActiveSupport::TestCase
password_confirmation: "password123"
)
party = Party.create!(
name: "Valid Party Name",
slug: "valid-party-name",
description: "Valid description for the party that is long enough",
event = Event.create!(
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",
@@ -181,7 +181,7 @@ class TicketTypeTest < ActiveSupport::TestCase
sale_start_at: Time.current,
sale_end_at: Time.current + 1.day,
requires_id: false,
party: party
event: event
)
assert ticket_type.save
end
@@ -194,10 +194,10 @@ class TicketTypeTest < ActiveSupport::TestCase
password_confirmation: "password123"
)
party = Party.create!(
name: "Valid Party Name",
slug: "valid-party-name",
description: "Valid description for the party that is long enough",
event = Event.create!(
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",
@@ -214,7 +214,7 @@ class TicketTypeTest < ActiveSupport::TestCase
sale_end_at: Time.current + 1.day,
requires_id: false,
minimum_age: nil,
party: party
event: event
)
assert ticket_type.save
end

4
test/models/user_test.rb Normal file → Executable file
View File

@@ -14,8 +14,8 @@ class UserTest < ActiveSupport::TestCase
end
# Test associations
test "should have many parties" do
association = User.reflect_on_association(:parties)
test "should have many events" do
association = User.reflect_on_association(:events)
assert_equal :has_many, association.macro
assert_equal :destroy, association.options[:dependent]
end

0
test/system/.keep Normal file → Executable file
View File

0
test/test_helper.rb Normal file → Executable file
View File