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

Loser name generation was not saving. Fixed that and added a test.

This commit is contained in:
2015-05-28 12:24:46 +00:00
parent c69a33fbae
commit d065e31818
2 changed files with 15 additions and 1 deletions

View File

@@ -10,8 +10,8 @@ module GeneratesLoserNames
elsif w.pool_bracket_type == "fourPoolsToSemi"
fourPoolsToSemiLoser(matches_by_weight)
end
saveMatches(matches_by_weight)
end
return matches_by_weight
end
def twoPoolsToSemiLoser(matches_by_weight)
@@ -54,4 +54,10 @@ module GeneratesLoserNames
seventhEighth.loser1_name = "Loser of #{consoSemis.select{|m| m.bracket_position_number == 1}.first.bout_number}"
seventhEighth.loser2_name = "Loser of #{consoSemis.select{|m| m.bracket_position_number == 2}.first.bout_number}"
end
def saveMatches(matches)
matches.each do |m|
m.save!
end
end
end

View File

@@ -131,5 +131,13 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
end
end
test "test loser name for 16 man bracket 3/4th place match" do
@matches = @tournament.matches.where(weight_id: 5)
@semi_bouts = @matches.where(bracket_position: 'Semis')
@third_fourth_match = @matches.where(bracket_position: '3/4').first
assert_equal "Loser of #{@semi_bouts.first.bout_number}", @third_fourth_match.loser1_name
end
#todo test crazy movements through each bracket?
end