1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

7 Commits

Author SHA1 Message Date
dependabot[bot]
6c6fc3c7ff Bump loofah from 2.25.0 to 2.25.1
Bumps [loofah](https://github.com/flavorjones/loofah) from 2.25.0 to 2.25.1.
- [Release notes](https://github.com/flavorjones/loofah/releases)
- [Changelog](https://github.com/flavorjones/loofah/blob/main/CHANGELOG.md)
- [Commits](https://github.com/flavorjones/loofah/compare/v2.25.0...v2.25.1)

---
updated-dependencies:
- dependency-name: loofah
  dependency-version: 2.25.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-18 21:07:47 +00:00
d359be3ea1 Fixed deprecations 2026-02-13 18:02:04 -05:00
e97aa0d680 Fixed N+1 on up_matches and added html cache. 2026-02-13 18:02:04 -05:00
ae8d995b2c Added a QR code page that generates a QR code for tournament directors to print out. 2026-02-11 18:23:14 -05:00
d57aaac09d Hide ads on schools#show, wrestlers#new, wrestlers#edit, and mats#show 2026-02-11 07:55:49 -05:00
fcc8a9b9a9 Updated to ruby 4.0.1 2026-02-10 17:58:22 -05:00
b51866e9d8 Added tests for hiding ads on lineup submission. 2026-02-09 18:36:56 -05:00
22 changed files with 395 additions and 73 deletions

View File

@@ -1 +1 @@
wrestlingdev
wrestlingdev

View File

@@ -1 +1 @@
ruby-3.2.0
ruby-4.0.1

View File

@@ -1,6 +1,6 @@
source 'https://rubygems.org'
ruby '3.2.0'
ruby '4.0.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '8.1.2'
@@ -67,6 +67,7 @@ gem 'influxdb-rails'
gem 'cancancan'
gem 'round_robin_tournament'
gem 'rb-readline'
gem 'rqrcode'
# Replacing Delayed Job with Solid Queue
# gem 'delayed_job_active_record'
gem 'solid_queue'
@@ -91,4 +92,3 @@ group :development, :test do
# rails-controller-testing is needed for assert_template
gem 'rails-controller-testing'
end

View File

@@ -79,7 +79,7 @@ GEM
base64 (0.3.0)
bcrypt (3.1.21)
bigdecimal (4.0.1)
bootsnap (1.22.0)
bootsnap (1.23.0)
msgpack (~> 1.2)
brakeman (8.0.2)
racc
@@ -91,6 +91,7 @@ GEM
bundler (>= 1.2.0)
thor (~> 1.0)
cancancan (3.6.1)
chunky_png (1.4.0)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
crass (1.0.6)
@@ -117,8 +118,9 @@ GEM
influxdb (~> 0.6, >= 0.6.4)
railties (>= 5.0)
io-console (0.8.2)
irb (1.16.0)
irb (1.17.0)
pp (>= 0.6.0)
prism (>= 1.3.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jbuilder (2.14.1)
@@ -132,7 +134,7 @@ GEM
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
logger (1.7.0)
loofah (2.25.0)
loofah (2.25.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.9.0)
@@ -155,12 +157,12 @@ GEM
railties (>= 7.1)
stimulus-rails
turbo-rails
mocha (3.0.1)
mocha (3.0.2)
ruby2_keywords (>= 0.0.5)
msgpack (1.8.0)
mysql2 (0.5.7)
bigdecimal
net-imap (0.6.2)
net-imap (0.6.3)
date
net-protocol
net-pop (0.1.2)
@@ -170,21 +172,21 @@ GEM
net-smtp (0.5.1)
net-protocol
nio4r (2.7.5)
nokogiri (1.19.0-aarch64-linux-gnu)
nokogiri (1.19.1-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.0-aarch64-linux-musl)
nokogiri (1.19.1-aarch64-linux-musl)
racc (~> 1.4)
nokogiri (1.19.0-arm-linux-gnu)
nokogiri (1.19.1-arm-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.0-arm-linux-musl)
nokogiri (1.19.1-arm-linux-musl)
racc (~> 1.4)
nokogiri (1.19.0-arm64-darwin)
nokogiri (1.19.1-arm64-darwin)
racc (~> 1.4)
nokogiri (1.19.0-x86_64-darwin)
nokogiri (1.19.1-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.19.0-x86_64-linux-gnu)
nokogiri (1.19.1-x86_64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.0-x86_64-linux-musl)
nokogiri (1.19.1-x86_64-linux-musl)
racc (~> 1.4)
parallel (1.27.0)
parser (3.3.10.1)
@@ -255,7 +257,7 @@ GEM
rainbow (3.1.1)
rake (13.3.1)
rb-readline (0.5.5)
rdoc (7.1.0)
rdoc (7.2.0)
erb
psych (>= 4.0.0)
tsort
@@ -263,7 +265,11 @@ GEM
reline (0.6.3)
io-console (~> 0.5)
round_robin_tournament (0.1.2)
rubocop (1.84.1)
rqrcode (3.2.0)
chunky_png (~> 1.0)
rqrcode_core (~> 2.0)
rqrcode_core (2.1.0)
rubocop (1.84.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
@@ -365,6 +371,7 @@ DEPENDENCIES
rails_12factor
rb-readline
round_robin_tournament
rqrcode
rubocop
sdoc
solid_cable
@@ -377,7 +384,7 @@ DEPENDENCIES
tzinfo-data
RUBY VERSION
ruby 3.2.0p0
ruby 4.0.1p0
BUNDLED WITH
2.6.9
4.0.3

View File

@@ -7,7 +7,7 @@ This application is being created to run a wrestling tournament.
**Public Production Url:** [https://wrestlingdev.com](https://wrestlingdev.com)
**App Info**
* Ruby 3.2.0
* Ruby 4.0.1
* Rails 8.1.2
* DB MySQL/MariaDB
* Solid Cache -> MySQL/MariaDB for html partial caching

View File

@@ -1,6 +1,6 @@
class TournamentsController < ApplicationController
before_action :set_tournament, only: [:all_results, :delete_school_keys, :generate_school_keys,:reset_bout_board,:calculate_team_scores,:bout_sheets,:swap,:weigh_in_sheet,:error,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:generate_matches,:bracket,:all_brackets]
before_action :check_access_manage, only: [:delete_school_keys, :generate_school_keys,:reset_bout_board,:calculate_team_scores,:swap,:weigh_in_sheet,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches]
before_action :set_tournament, only: [:all_results, :delete_school_keys, :generate_school_keys,:reset_bout_board,:calculate_team_scores,:bout_sheets,:swap,:weigh_in_sheet,:error,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:generate_matches,:bracket,:all_brackets,:qrcode]
before_action :check_access_manage, only: [:delete_school_keys, :generate_school_keys,:reset_bout_board,:calculate_team_scores,:swap,:weigh_in_sheet,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches,:qrcode]
before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
before_action :check_tournament_errors, only: [:generate_matches]
before_action :check_for_matches, only: [:all_results,:up_matches,:bracket,:all_brackets]
@@ -196,6 +196,11 @@ class TournamentsController < ApplicationController
end
def qrcode
@tournament_url = tournament_url(@tournament)
@qrcode = RQRCode::QRCode.new(@tournament_url)
end
def up_matches
# .where.not(loser1_name: 'BYE') won't return matches with NULL loser1_name

View File

@@ -1,9 +1,15 @@
module ApplicationHelper
def hide_ads?
return false unless controller_name == "schools"
return false unless %w[show edit new].include?(action_name)
user_signed_in? || school_permission_key_present?
case controller_name
when "schools"
action_name == "show" && (user_signed_in? || school_permission_key_present?)
when "wrestlers"
%w[new edit].include?(action_name) && (user_signed_in? || school_permission_key_present?)
when "mats"
action_name == "show" && user_signed_in?
else
false
end
end
def school_permission_key_present?

View File

@@ -8,6 +8,8 @@ class Mat < ApplicationRecord
QUEUE_SLOTS = %w[queue1 queue2 queue3 queue4].freeze
after_save :clear_queue_matches_cache
def assign_next_match
slot = first_empty_queue_slot
return true unless slot
@@ -86,8 +88,20 @@ class Mat < ApplicationRecord
QUEUE_SLOTS.map { |slot| public_send(slot) }
end
# used to prevent N+1 query on each mat
def queue_matches
queue_match_ids.map { |match_id| match_id ? Match.find_by(id: match_id) : nil }
slot_ids = queue_match_ids
if @queue_matches.nil? || @queue_match_slot_ids != slot_ids
ids = slot_ids.compact
@queue_matches = if ids.empty?
[nil, nil, nil, nil]
else
matches_by_id = Match.where(id: ids).index_by(&:id)
slot_ids.map { |match_id| match_id ? matches_by_id[match_id] : nil }
end
@queue_match_slot_ids = slot_ids
end
@queue_matches
end
def queue1_match
@@ -175,9 +189,13 @@ class Mat < ApplicationRecord
private
def clear_queue_matches_cache
@queue_matches = nil
@queue_match_slot_ids = nil
end
def queue_match_at(position)
match_id = public_send("queue#{position}")
match_id ? Match.find_by(id: match_id) : nil
queue_matches[position - 1]
end
def first_empty_queue_slot

View File

@@ -38,9 +38,10 @@
<li><strong>Pages</strong></li>
<li></span> <%= link_to "Edit Tournament Info", edit_tournament_path(@tournament) %></li>
<li><%= link_to "Weigh In Page" , "/tournaments/#{@tournament.id}/weigh_in" %></li>
<li><%= link_to "All Matches" , "/tournaments/#{@tournament.id}/matches" %></li>
<li><%= link_to "Full Screen Bout Board" , "/tournaments/#{@tournament.id}/up_matches?print=true" , target: :_blank %></li>
<li><%= link_to "Deduct Team Points" , "/tournaments/#{@tournament.id}/teampointadjust" %></li>
<li><%= link_to "All Matches" , "/tournaments/#{@tournament.id}/matches" %></li>
<li><%= link_to "Full Screen Bout Board" , "/tournaments/#{@tournament.id}/up_matches?print=true" , target: :_blank %></li>
<li><%= link_to "QR Code (Full Screen)" , "/tournaments/#{@tournament.id}/qrcode?print=true" , target: :_blank %></li>
<li><%= link_to "Deduct Team Points" , "/tournaments/#{@tournament.id}/teampointadjust" %></li>
<li><%= link_to "View All Mat Assignment Rules", tournament_mat_assignment_rules_path(@tournament) %></li>
<li><%= link_to 'Manage Backups', tournament_tournament_backups_path(@tournament) %></li>
<li><%= link_to "Reset Bout Board", reset_bout_board_tournament_path(@tournament), data: { turbo_method: :post, turbo_confirm: "Are you sure you want to reset the bout board?" } %></li>

View File

@@ -0,0 +1,34 @@
<% queue1_match, queue2_match, queue3_match, queue4_match = mat.queue_matches %>
<% cache ["up_matches_mat_row", mat, mat.queue1, mat.queue2, mat.queue3, mat.queue4] do %>
<tr>
<td><%= mat.name %></td>
<td>
<% if queue1_match %><strong><%= queue1_match.bout_number %></strong> (<%= queue1_match.bracket_position %>)<br>
<%= queue1_match.weight_max %> lbs
<br><%= queue1_match.w1_bracket_name %> vs. <br>
<%= queue1_match.w2_bracket_name %>
<% end %>
</td>
<td>
<% if queue2_match %><strong><%= queue2_match.bout_number %></strong> (<%= queue2_match.bracket_position %>)<br>
<%= queue2_match.weight_max %> lbs
<br><%= queue2_match.w1_bracket_name %> vs. <br>
<%= queue2_match.w2_bracket_name %>
<% end %>
</td>
<td>
<% if queue3_match %><strong><%= queue3_match.bout_number %></strong> (<%= queue3_match.bracket_position %>)<br>
<%= queue3_match.weight_max %> lbs
<br><%= queue3_match.w1_bracket_name %> vs. <br>
<%= queue3_match.w2_bracket_name %>
<% end %>
</td>
<td>
<% if queue4_match %><strong><%= queue4_match.bout_number %></strong> (<%= queue4_match.bracket_position %>)<br>
<%= queue4_match.weight_max %> lbs
<br><%= queue4_match.w1_bracket_name %> vs. <br>
<%= queue4_match.w2_bracket_name %>
<% end %>
</td>
</tr>
<% end %>

View File

@@ -0,0 +1,50 @@
<style>
.qr-page {
min-height: 100vh;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: 24px;
}
.qr-page h1 {
margin: 0 0 24px 0;
font-size: 40px;
font-weight: 700;
}
.qr-code {
width: 100%;
display: flex;
justify-content: center;
}
.qr-code svg {
width: min(80vmin, 720px);
height: auto;
display: block;
margin: 0;
}
@media print {
body {
margin: 0;
}
}
</style>
<div class="qr-page">
<h1><%= @tournament.name %> Brackets and Results Available Here</h1>
<div class="qr-code">
<%= raw @qrcode.as_svg(
offset: 0,
color: "000",
shape_rendering: "crispEdges",
module_size: 8,
standalone: true
) %>
</div>
</div>

View File

@@ -1,4 +1,3 @@
<% cache ["#{@tournament.id}_up_matches", @tournament] do %>
<script>
// $(document).ready(function() {
// $('#matchList').dataTable();
@@ -42,37 +41,7 @@
<tbody>
<% @mats.each.map do |m| %>
<tr>
<td><%= m.name %></td>
<td>
<% if m.queue1_match %><strong><%=m.queue1_match.bout_number%></strong> (<%= m.queue1_match.bracket_position %>)<br>
<%= m.queue1_match.weight_max %> lbs
<br><%= m.queue1_match.w1_bracket_name %> vs. <br>
<%= m.queue1_match.w2_bracket_name %>
<% end %>
</td>
<td>
<% if m.queue2_match %><strong><%=m.queue2_match.bout_number%></strong> (<%= m.queue2_match.bracket_position %>)<br>
<%= m.queue2_match.weight_max %> lbs
<br><%= m.queue2_match.w1_bracket_name %> vs. <br>
<%= m.queue2_match.w2_bracket_name %>
<% end %>
</td>
<td>
<% if m.queue3_match %><strong><%=m.queue3_match.bout_number%></strong> (<%= m.queue3_match.bracket_position %>)<br>
<%= m.queue3_match.weight_max %> lbs
<br><%= m.queue3_match.w1_bracket_name %> vs. <br>
<%= m.queue3_match.w2_bracket_name %>
<% end %>
</td>
<td>
<% if m.queue4_match %><strong><%=m.queue4_match.bout_number%></strong> (<%= m.queue4_match.bracket_position %>)<br>
<%= m.queue4_match.weight_max %> lbs
<br><%= m.queue4_match.w1_bracket_name %> vs. <br>
<%= m.queue4_match.w2_bracket_name %>
<% end %>
</td>
</tr>
<%= render "up_matches_mat_row", mat: m %>
<% end %>
</tbody>
</table>
@@ -104,4 +73,3 @@
</table>
<br>
<% end %>

View File

@@ -25,9 +25,6 @@ module Wrestling
config.active_record.schema_format = :ruby
config.active_record.dump_schemas = :all
# Fix deprecation warning for to_time in Rails 8.1
config.active_support.to_time_preserves_timezone = :zone
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
@@ -57,6 +54,5 @@ module Wrestling
config.active_support.cache_format_version = 7.1
config.load_defaults 8.1
config.active_support.to_time_preserves_timezone = :zone
end
end

View File

@@ -73,6 +73,7 @@ Wrestling::Application.routes.draw do
get 'tournaments/:id/bout_sheets' => 'tournaments#bout_sheets'
get 'tournaments/:id/no_matches' => 'tournaments#no_matches'
get 'tournaments/:id/matches' => 'tournaments#matches'
get 'tournaments/:id/qrcode' => 'tournaments#qrcode'
get 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :tournament_delegate
post 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :set_tournament_delegate
delete 'tournaments/:id/:delegate/remove_delegate' => 'tournaments#remove_delegate', :as => :delete_delegate_path

View File

@@ -1,4 +1,4 @@
FROM ruby:3.2.0
FROM ruby:4.0.1
# Accept build arguments for user/group IDs
ARG USER_ID=1000

View File

@@ -1,4 +1,4 @@
FROM ruby:3.2.0-slim
FROM ruby:4.0.1-slim
#HEALTHCHECK --start-period=60s CMD curl http://127.0.0.1/
@@ -15,6 +15,8 @@ RUN apt-get -qq update --fix-missing \
libsqlite3-dev \
wget \
default-libmysqlclient-dev \
libyaml-dev \
pkg-config \
nodejs \
tzdata \
git \

View File

@@ -66,6 +66,15 @@ class MatsControllerTest < ActionController::TestCase
def redirect
assert_redirected_to '/static_pages/not_allowed'
end
def assert_ads_hidden
assert_no_match(/blocked_message/, response.body)
assert_no_match(/adsbygoogle/, response.body)
end
def assert_ads_visible
assert_match(/blocked_message/, response.body)
end
def no_matches
assert_redirected_to "/tournaments/#{@tournament.id}/no_matches"
@@ -221,6 +230,13 @@ class MatsControllerTest < ActionController::TestCase
success
end
test "ads are hidden on mat show" do
sign_in_owner
show
success
assert_ads_hidden
end
test "redirect to mat show when posting a match from mat show" do
sign_in_owner
post_match_update_from_mat_show

View File

@@ -60,6 +60,15 @@ class SchoolsControllerTest < ActionController::TestCase
assert_redirected_to '/static_pages/not_allowed'
end
def assert_ads_hidden
assert_no_match(/blocked_message/, response.body)
assert_no_match(/adsbygoogle/, response.body)
end
def assert_ads_visible
assert_match(/blocked_message/, response.body)
end
def baums_import
baums_text = "***** 2019-01-09 13:36:50 *****
Some School
@@ -399,6 +408,27 @@ Some Guy
success
end
test "ads are hidden on school show when logged in" do
sign_in_owner
get_show
success
assert_ads_hidden
end
test "ads are hidden on school show with school permission key" do
@tournament.update(is_public: false)
get_show(school_permission_key: @school_permission_key)
success
assert_ads_hidden
end
test "ads are visible on school show for anonymous user without key" do
@tournament.update(is_public: true)
get_show
success
assert_ads_visible
end
test "non logged in user cannot edit school with invalid school_permission_key" do
@tournament.update(is_public: false)
get_edit(school_permission_key: "invalid-key")

View File

@@ -27,6 +27,10 @@ class TournamentsControllerTest < ActionController::TestCase
def get_up_matches
get :up_matches, params: { id: 1 }
end
def get_qrcode(params = {})
get :qrcode, params: { id: 1 }.merge(params)
end
def get_edit
get :edit, params: { id: 1 }
@@ -192,6 +196,47 @@ class TournamentsControllerTest < ActionController::TestCase
assert_redirected_to '/static_pages/not_allowed'
end
test "logged in non owner and non delegate cannot access qrcode" do
sign_in_non_owner
get_qrcode
redirect
end
test "non logged in user cannot access qrcode" do
get_qrcode
redirect
end
test "non logged in user with valid school permission key cannot access qrcode" do
@school.update(permission_key: "valid-key")
get_qrcode(school_permission_key: "valid-key")
redirect
end
test "non logged in user with invalid school permission key cannot access qrcode" do
@school.update(permission_key: "valid-key")
get_qrcode(school_permission_key: "invalid-key")
redirect
end
test "logged in owner can access qrcode" do
sign_in_owner
get_qrcode
success
end
test "logged in tournament delegate can access qrcode" do
sign_in_delegate
get_qrcode
success
end
test "logged in school delegate cannot access qrcode" do
sign_in_school_delegate
get_qrcode
redirect
end
test "logged in user should not post update tournament if not owner" do
sign_in_non_owner
post_update

View File

@@ -0,0 +1,84 @@
require "test_helper"
class UpMatchesCacheTest < ActionController::TestCase
tests TournamentsController
setup do
create_double_elim_tournament_1_6_with_multiple_weights_and_multiple_mats(16, 4, 2)
@tournament.update!(user_id: users(:one).id)
@tournament.reset_and_fill_bout_board
sign_in users(:one)
@original_perform_caching = ActionController::Base.perform_caching
ActionController::Base.perform_caching = true
Rails.cache.clear
end
teardown do
Rails.cache.clear
ActionController::Base.perform_caching = @original_perform_caching
end
test "up_matches row fragments hit cache and invalidate when a mat queue changes" do
first_events = cache_events_for_up_matches do
get :up_matches, params: { id: @tournament.id }
assert_response :success
end
assert_operator cache_writes(first_events), :>, 0, "Expected initial render to write row fragments"
second_events = cache_events_for_up_matches do
get :up_matches, params: { id: @tournament.id }
assert_response :success
end
assert_equal 0, cache_writes(second_events), "Expected second render to reuse cached row fragments"
assert_operator cache_hits(second_events), :>, 0, "Expected second render to have cache hits"
mat = @tournament.mats.first
mat.reload
movable_match = mat.queue2_match || mat.queue1_match
assert movable_match, "Expected at least one queued match to move"
mat.assign_match_to_queue!(movable_match, 4)
third_events = cache_events_for_up_matches do
get :up_matches, params: { id: @tournament.id }
assert_response :success
end
assert_operator cache_writes(third_events), :>, 0, "Expected queue change to invalidate and rewrite at least one row fragment"
end
private
def cache_events_for_up_matches
events = []
subscriber = lambda do |name, _start, _finish, _id, payload|
key = payload[:key].to_s
next unless key.include?("up_matches_mat_row")
events << { name: name, hit: payload[:hit] }
end
ActiveSupport::Notifications.subscribed(
subscriber,
/cache_(read|write|fetch_hit|generate)\.active_support/
) do
yield
end
events
end
def cache_writes(events)
events.count { |event| event[:name] == "cache_write.active_support" }
end
def cache_hits(events)
events.count do |event|
event[:name] == "cache_fetch_hit.active_support" ||
(event[:name] == "cache_read.active_support" && event[:hit])
end
end
end

View File

@@ -56,6 +56,15 @@ class WrestlersControllerTest < ActionController::TestCase
assert_redirected_to '/static_pages/not_allowed'
end
def assert_ads_hidden
assert_no_match(/blocked_message/, response.body)
assert_no_match(/adsbygoogle/, response.body)
end
def assert_ads_visible
assert_match(/blocked_message/, response.body)
end
test "logged in tournament owner should get edit wrestler page" do
sign_in_owner
get_edit
@@ -305,4 +314,39 @@ class WrestlersControllerTest < ActionController::TestCase
assert_select "a[href=?]", school_path(@school), text: /Back to/
end
test "ads are hidden on wrestler new" do
sign_in_owner
new
success
assert_ads_hidden
end
test "ads are hidden on wrestler edit" do
sign_in_owner
get_edit
success
assert_ads_hidden
end
test "ads are hidden on wrestler new with school permission key" do
valid_key = @school.permission_key
get :new, params: { school: @school.id, school_permission_key: valid_key }
success
assert_ads_hidden
end
test "ads are hidden on wrestler edit with school permission key" do
valid_key = @school.permission_key
get :edit, params: { id: @wrestler.id, school_permission_key: valid_key }
success
assert_ads_hidden
end
test "ads are visible on wrestler show" do
sign_in_owner
get :show, params: { id: @wrestler.id }
success
assert_ads_visible
end
end

View File

@@ -10,5 +10,20 @@ class MatTest < ActiveSupport::TestCase
assert_not mat.valid?
assert_equal [:tournament, :name], mat.errors.attribute_names
end
test "queue_matches refreshes after queue slots change and record reloads" do
create_double_elim_tournament_1_6_with_multiple_weights_and_multiple_mats(16, 4, 1)
@tournament.reset_and_fill_bout_board
mat = @tournament.mats.first
initial_queue_ids = mat.queue_matches.map { |match| match&.id }
assert initial_queue_ids.compact.any?, "Expected initial queue to contain matches"
Mat.where(id: mat.id).update_all(queue1: nil, queue2: nil, queue3: nil, queue4: nil)
mat.reload
refreshed_queue_ids = mat.queue_matches.map { |match| match&.id }
assert_equal [nil, nil, nil, nil], refreshed_queue_ids, "Expected queue_matches to refresh after reload and slot changes"
end
end