develop #3

Merged
kbe merged 227 commits from develop into main 2025-09-16 14:35:23 +00:00
7 changed files with 42 additions and 42 deletions
Showing only changes of commit 8d2127fce2 - Show all commits

View File

@@ -1,6 +1,6 @@
class OnboardingController < ApplicationController class OnboardingController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
before_action :redirect_if_onboarding_complete, except: [:complete] before_action :redirect_if_onboarding_complete, except: [ :complete ]
def index def index
# Display the onboarding form # Display the onboarding form
@@ -10,7 +10,7 @@ class OnboardingController < ApplicationController
if onboarding_params_valid? if onboarding_params_valid?
current_user.update!(onboarding_params) current_user.update!(onboarding_params)
current_user.complete_onboarding! current_user.complete_onboarding!
flash[:notice] = "Bienvenue sur #{Rails.application.config.app_name} ! Votre profil a été configuré avec succès." flash[:notice] = "Bienvenue sur #{Rails.application.config.app_name} ! Votre profil a été configuré avec succès."
redirect_to dashboard_path redirect_to dashboard_path
else else
@@ -26,7 +26,7 @@ class OnboardingController < ApplicationController
end end
def onboarding_params_valid? def onboarding_params_valid?
onboarding_params[:first_name].present? && onboarding_params[:first_name].present? &&
onboarding_params[:last_name].present? onboarding_params[:last_name].present?
end end

View File

@@ -9,19 +9,19 @@ class PagesController < ApplicationController
def home def home
# Featured events for the main grid (6-9 events like Shotgun) # Featured events for the main grid (6-9 events like Shotgun)
@featured_events = Event.published.featured.includes(:ticket_types).limit(9) @featured_events = Event.published.featured.includes(:ticket_types).limit(9)
# If no featured events, show latest published events # If no featured events, show latest published events
if @featured_events.empty? if @featured_events.empty?
@featured_events = Event.published.includes(:ticket_types).order(created_at: :desc).limit(9) @featured_events = Event.published.includes(:ticket_types).order(created_at: :desc).limit(9)
end end
# Upcoming events for additional content # Upcoming events for additional content
@upcoming_events = Event.published.upcoming.limit(6) @upcoming_events = Event.published.upcoming.limit(6)
# Site metrics for landing page (with realistic fake data for demo) # Site metrics for landing page (with realistic fake data for demo)
@total_events = [Event.published.count, 50].max # At least 50 events for demo @total_events = [ Event.published.count, 50 ].max # At least 50 events for demo
@total_users = [User.count, 2500].max # At least 2500 users for demo @total_users = [ User.count, 2500 ].max # At least 2500 users for demo
@events_this_month = [Event.published.where(created_at: 1.month.ago..Time.current).count, 12].max # At least 12 this month @events_this_month = [ Event.published.where(created_at: 1.month.ago..Time.current).count, 12 ].max # At least 12 this month
@active_cities = 5 # Fixed number for demo @active_cities = 5 # Fixed number for demo
end end

View File

@@ -4,7 +4,7 @@ class ApplicationControllerOnboardingTest < ActionDispatch::IntegrationTest
setup do setup do
@user_without_onboarding = users(:one) @user_without_onboarding = users(:one)
@user_without_onboarding.update!(onboarding_completed: false) @user_without_onboarding.update!(onboarding_completed: false)
@user_with_onboarding = users(:two) @user_with_onboarding = users(:two)
@user_with_onboarding.update!(onboarding_completed: true, first_name: "John", last_name: "Doe") @user_with_onboarding.update!(onboarding_completed: true, first_name: "John", last_name: "Doe")
end end
@@ -54,4 +54,4 @@ class ApplicationControllerOnboardingTest < ActionDispatch::IntegrationTest
get onboarding_path get onboarding_path
assert_response :success assert_response :success
end end
end end

View File

@@ -4,7 +4,7 @@ class OnboardingControllerTest < ActionDispatch::IntegrationTest
setup do setup do
@user_without_onboarding = users(:one) @user_without_onboarding = users(:one)
@user_without_onboarding.update!(onboarding_completed: false) @user_without_onboarding.update!(onboarding_completed: false)
@user_with_onboarding = users(:two) @user_with_onboarding = users(:two)
@user_with_onboarding.update!(onboarding_completed: true, first_name: "John", last_name: "Doe") @user_with_onboarding.update!(onboarding_completed: true, first_name: "John", last_name: "Doe")
end end
@@ -30,20 +30,20 @@ class OnboardingControllerTest < ActionDispatch::IntegrationTest
test "should complete onboarding with valid data" do test "should complete onboarding with valid data" do
sign_in @user_without_onboarding sign_in @user_without_onboarding
assert_not @user_without_onboarding.onboarding_completed? assert_not @user_without_onboarding.onboarding_completed?
post complete_onboarding_path, params: { post complete_onboarding_path, params: {
user: { user: {
first_name: "Jane", first_name: "Jane",
last_name: "Smith" last_name: "Smith"
} }
} }
assert_redirected_to dashboard_path assert_redirected_to dashboard_path
follow_redirect! follow_redirect!
assert_select ".notification", /Bienvenue sur Aperonight/ assert_select ".notification", /Bienvenue sur Aperonight/
@user_without_onboarding.reload @user_without_onboarding.reload
assert @user_without_onboarding.onboarding_completed? assert @user_without_onboarding.onboarding_completed?
assert_equal "Jane", @user_without_onboarding.first_name assert_equal "Jane", @user_without_onboarding.first_name
@@ -52,34 +52,34 @@ class OnboardingControllerTest < ActionDispatch::IntegrationTest
test "should not complete onboarding without required fields" do test "should not complete onboarding without required fields" do
sign_in @user_without_onboarding sign_in @user_without_onboarding
post complete_onboarding_path, params: { post complete_onboarding_path, params: {
user: { user: {
first_name: "", first_name: "",
last_name: "Smith" last_name: "Smith"
} }
} }
assert_response :success assert_response :success
assert_select ".notification", /Veuillez remplir tous les champs requis/ assert_select ".notification", /Veuillez remplir tous les champs requis/
@user_without_onboarding.reload @user_without_onboarding.reload
assert_not @user_without_onboarding.onboarding_completed? assert_not @user_without_onboarding.onboarding_completed?
end end
test "should not complete onboarding without last name" do test "should not complete onboarding without last name" do
sign_in @user_without_onboarding sign_in @user_without_onboarding
post complete_onboarding_path, params: { post complete_onboarding_path, params: {
user: { user: {
first_name: "Jane", first_name: "Jane",
last_name: "" last_name: ""
} }
} }
assert_response :success assert_response :success
assert_select ".notification", /Veuillez remplir tous les champs requis/ assert_select ".notification", /Veuillez remplir tous les champs requis/
@user_without_onboarding.reload @user_without_onboarding.reload
assert_not @user_without_onboarding.onboarding_completed? assert_not @user_without_onboarding.onboarding_completed?
end end

View File

@@ -24,7 +24,7 @@ class TicketMailerTest < ActionMailer::TestCase
assert_equal [ "no-reply@aperonight.fr" ], email.from assert_equal [ "no-reply@aperonight.fr" ], email.from
assert_equal [ @user.email ], email.to assert_equal [ @user.email ], email.to
assert_equal "Confirmation d'achat - #{@event.name}", email.subject assert_equal "Confirmation d'achat - #{@event.name}", email.subject
# Check if we have any content # Check if we have any content
content = "" content = ""
if email.html_part if email.html_part
@@ -34,7 +34,7 @@ class TicketMailerTest < ActionMailer::TestCase
else else
content = email.body.to_s content = email.body.to_s
end end
# If still empty, try to get content from parts # If still empty, try to get content from parts
if content.empty? && email.parts.any? if content.empty? && email.parts.any?
email.parts.each do |part| email.parts.each do |part|
@@ -44,7 +44,7 @@ class TicketMailerTest < ActionMailer::TestCase
end end
end end
end end
# Instead of strict matching, just check that content exists # Instead of strict matching, just check that content exists
assert content.length > 0, "Email body should not be empty" assert content.length > 0, "Email body should not be empty"
assert_match @event.name, content assert_match @event.name, content
@@ -64,7 +64,7 @@ class TicketMailerTest < ActionMailer::TestCase
assert_equal [ "no-reply@aperonight.fr" ], email.from assert_equal [ "no-reply@aperonight.fr" ], email.from
assert_equal [ @ticket.user.email ], email.to assert_equal [ @ticket.user.email ], email.to
assert_equal "Confirmation d'achat - #{@ticket.event.name}", email.subject assert_equal "Confirmation d'achat - #{@ticket.event.name}", email.subject
# Check if we have any content # Check if we have any content
content = "" content = ""
if email.html_part if email.html_part
@@ -74,7 +74,7 @@ class TicketMailerTest < ActionMailer::TestCase
else else
content = email.body.to_s content = email.body.to_s
end end
# If still empty, try to get content from parts # If still empty, try to get content from parts
if content.empty? && email.parts.any? if content.empty? && email.parts.any?
email.parts.each do |part| email.parts.each do |part|
@@ -84,7 +84,7 @@ class TicketMailerTest < ActionMailer::TestCase
end end
end end
end end
# Instead of strict matching, just check that content exists # Instead of strict matching, just check that content exists
assert content.length > 0, "Email body should not be empty" assert content.length > 0, "Email body should not be empty"
assert_match @ticket.event.name, content assert_match @ticket.event.name, content
@@ -105,7 +105,7 @@ class TicketMailerTest < ActionMailer::TestCase
assert_equal [ "no-reply@aperonight.fr" ], email.from assert_equal [ "no-reply@aperonight.fr" ], email.from
assert_equal [ @user.email ], email.to assert_equal [ @user.email ], email.to
assert_equal "Rappel : #{@event.name} dans une semaine", email.subject assert_equal "Rappel : #{@event.name} dans une semaine", email.subject
# Check content properly # Check content properly
content = "" content = ""
if email.html_part if email.html_part
@@ -115,7 +115,7 @@ class TicketMailerTest < ActionMailer::TestCase
else else
content = email.body.to_s content = email.body.to_s
end end
assert content.length > 0, "Email body should not be empty" assert content.length > 0, "Email body should not be empty"
assert_match /une semaine/, content assert_match /une semaine/, content
assert_match @event.name, content assert_match @event.name, content
@@ -136,7 +136,7 @@ class TicketMailerTest < ActionMailer::TestCase
end end
assert_equal "Rappel : #{@event.name} demain", email.subject assert_equal "Rappel : #{@event.name} demain", email.subject
# Check content properly # Check content properly
content = "" content = ""
if email.html_part if email.html_part
@@ -146,7 +146,7 @@ class TicketMailerTest < ActionMailer::TestCase
else else
content = email.body.to_s content = email.body.to_s
end end
assert content.length > 0, "Email body should not be empty" assert content.length > 0, "Email body should not be empty"
assert_match /demain/, content assert_match /demain/, content
end end
@@ -161,7 +161,7 @@ class TicketMailerTest < ActionMailer::TestCase
end end
assert_equal "C'est aujourd'hui : #{@event.name}", email.subject assert_equal "C'est aujourd'hui : #{@event.name}", email.subject
# Check content properly # Check content properly
content = "" content = ""
if email.html_part if email.html_part
@@ -171,7 +171,7 @@ class TicketMailerTest < ActionMailer::TestCase
else else
content = email.body.to_s content = email.body.to_s
end end
assert content.length > 0, "Email body should not be empty" assert content.length > 0, "Email body should not be empty"
assert_match /aujourd'hui/, content assert_match /aujourd'hui/, content
end end
@@ -186,7 +186,7 @@ class TicketMailerTest < ActionMailer::TestCase
end end
assert_equal "Rappel : #{@event.name} dans 3 jours", email.subject assert_equal "Rappel : #{@event.name} dans 3 jours", email.subject
# Check content properly # Check content properly
content = "" content = ""
if email.html_part if email.html_part
@@ -196,7 +196,7 @@ class TicketMailerTest < ActionMailer::TestCase
else else
content = email.body.to_s content = email.body.to_s
end end
assert content.length > 0, "Email body should not be empty" assert content.length > 0, "Email body should not be empty"
assert_match /3 jours/, content assert_match /3 jours/, content
end end

View File

@@ -74,21 +74,21 @@ class UserTest < ActiveSupport::TestCase
test "should complete onboarding" do test "should complete onboarding" do
user = users(:one) user = users(:one)
user.update!(onboarding_completed: false) user.update!(onboarding_completed: false)
assert user.needs_onboarding?, "User should need onboarding initially" assert user.needs_onboarding?, "User should need onboarding initially"
user.complete_onboarding! user.complete_onboarding!
assert_not user.needs_onboarding?, "User should not need onboarding after completion" assert_not user.needs_onboarding?, "User should not need onboarding after completion"
assert user.onboarding_completed?, "User should have completed onboarding" assert user.onboarding_completed?, "User should have completed onboarding"
end end
test "needs_onboarding? should return correct value" do test "needs_onboarding? should return correct value" do
user = users(:one) user = users(:one)
user.update!(onboarding_completed: false) user.update!(onboarding_completed: false)
assert user.needs_onboarding?, "User with false onboarding_completed should need onboarding" assert user.needs_onboarding?, "User with false onboarding_completed should need onboarding"
user.update!(onboarding_completed: true) user.update!(onboarding_completed: true)
assert_not user.needs_onboarding?, "User with true onboarding_completed should not need onboarding" assert_not user.needs_onboarding?, "User with true onboarding_completed should not need onboarding"
end end

View File

@@ -17,7 +17,7 @@ module ActiveSupport
fixtures :all fixtures :all
# Add more helper methods to be used by all tests here... # Add more helper methods to be used by all tests here...
# Helper to create users with completed onboarding by default for tests # Helper to create users with completed onboarding by default for tests
def create_test_user(attributes = {}) def create_test_user(attributes = {})
User.create!({ User.create!({