1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-02 21:24:25 +00:00

Fixed a number of N+1 issues on low traffic pages. I also added relevant html tests for these pages.

This commit is contained in:
2026-02-17 22:27:11 -05:00
parent d359be3ea1
commit 8670ce38c3
16 changed files with 330 additions and 103 deletions

View File

@@ -36,4 +36,41 @@ class StaticPagesControllerTest < ActionController::TestCase
get :my_tournaments
success
end
test "my_tournaments page lists delegated tournament and delegated school once in html" do
user = users(:two)
sign_in_non_owner
delegated_tournament = Tournament.create!(
name: "Delegated Tournament #{SecureRandom.hex(4)}",
address: "123 Delegate St",
director: "Director",
director_email: "delegate_tournament_#{SecureRandom.hex(4)}@example.com",
tournament_type: "Pool to bracket",
date: Date.today,
is_public: true
)
TournamentDelegate.create!(tournament_id: delegated_tournament.id, user_id: user.id)
school_tournament = Tournament.create!(
name: "School Tournament #{SecureRandom.hex(4)}",
address: "456 School St",
director: "Director",
director_email: "delegate_school_#{SecureRandom.hex(4)}@example.com",
tournament_type: "Pool to bracket",
date: Date.today + 1,
is_public: true
)
delegated_school = School.create!(
name: "Delegated School #{SecureRandom.hex(4)}",
tournament_id: school_tournament.id
)
SchoolDelegate.create!(school_id: delegated_school.id, user_id: user.id)
get :my_tournaments
assert_response :success
assert_equal 1, response.body.scan(delegated_tournament.name).size
assert_equal 1, response.body.scan(delegated_school.name).size
assert_equal 1, response.body.scan(school_tournament.name).size
end
end