Files
aperonight/test/controllers/promoter/events_controller_test.rb
kbe 4cde466f9a Add comprehensive unit test coverage for controllers, models, and services
- Translate French comments to English in controllers and tests
- Fix test failures: route helpers, validations, MySQL transaction issues
- Add Timecop for time-dependent tests and update database config for isolation
2025-09-15 19:27:06 +02:00

31 lines
1.5 KiB
Ruby

require "test_helper"
class Promoter::EventsControllerTest < ActionDispatch::IntegrationTest
setup do
@promoter = User.create!(email: "promoter@example.com", password: "password123", password_confirmation: "password123", is_professionnal: true, onboarding_completed: true)
@event = Event.create!(name: "Test Event", slug: "test-event", description: "A valid description for the test event that is long enough to meet the minimum character requirement", latitude: 48.8566, longitude: 2.3522, venue_name: "Venue", venue_address: "Address", user: @promoter, start_time: 1.week.from_now, end_time: 1.week.from_now + 3.hours, state: :draft)
end
test "should require authentication for index" do
get promoter_events_path
assert_redirected_to new_user_session_path
end
test "should get index for authenticated promoter" do
sign_in @promoter
get promoter_events_path
assert_response :success
end
test "should show promoter's events only" do
sign_in @promoter
other_event = Event.create!(name: "Other Event", slug: "other", description: "Valid description for the event", latitude: 48.0, longitude: 2.0, venue_name: "V", venue_address: "A", user_id: users(:one).id, start_time: 1.day.from_now, end_time: 2.days.from_now, state: :draft)
get promoter_events_path
assert_response :success
assert_includes assigns(:events), @event
assert_not_includes assigns(:events), other_event
end
# Add tests for new, create, etc. as needed
end