1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-24 17:04:43 +00:00

Made a test for the swap wrestlers service

This commit is contained in:
2017-09-04 21:53:28 -04:00
parent e40851d9fc
commit 16d63b52cd
5 changed files with 131 additions and 1 deletions

View File

@@ -15,3 +15,8 @@ three:
name: Central Crossing
tournament_id: 2
swap_wrestlers:
id: 4
name: Central Crossing
tournament_id: 3

View File

@@ -20,4 +20,12 @@ two:
user_id: 1
date: 2015-12-30
swap_wrestlers_tournament:
id: 3
name: Comet Classic 2
address: Some Place
director: Jacob Cody Wimer
director_email: jacob.wimer@gmail.com
tournament_type: Pool to bracket
user_id: 1
date: 2015-12-30

View File

@@ -30,3 +30,8 @@ six:
id: 6
max: 285
tournament_id: 1
swap_wrestlers:
id: 7
max: 138
tournament_id: 3

View File

@@ -689,5 +689,89 @@ tournament_1_wrestler_53:
extra:
pool: 1
swap_wrestlers_wrestler_1:
id: 54
name: Guy1
school_id: 4
weight_id: 7
original_seed: 1
season_loss: 0
season_win: 0
criteria:
extra:
swap_wrestlers_wrestler_2:
id: 55
name: Guy2
school_id: 4
weight_id: 7
original_seed: 2
season_loss: 0
season_win: 0
criteria:
extra:
swap_wrestlers_wrestler_3:
name: Guy3
school_id: 4
weight_id: 7
original_seed: 3
season_loss: 0
season_win: 0
criteria:
extra:
swap_wrestlers_wrestler_4:
name: Guy4
school_id: 4
weight_id: 7
original_seed: 4
season_loss: 0
season_win: 0
criteria:
extra:
swap_wrestlers_wrestler_5:
name: Guy5
school_id: 4
weight_id: 7
original_seed:
season_loss: 0
season_win: 0
criteria:
extra:
swap_wrestlers_wrestler_6:
name: Guy6
school_id: 4
weight_id: 7
original_seed:
season_loss: 0
season_win: 0
criteria:
extra:
swap_wrestlers_wrestler_7:
name: Guy7
school_id: 4
weight_id: 7
original_seed:
season_loss: 0
season_win: 0
criteria:
extra:
swap_wrestlers_wrestler_8:
name: Guy8
school_id: 4
weight_id: 7
original_seed:
season_loss: 0
season_win: 0
criteria:
extra:

View File

@@ -0,0 +1,28 @@
require 'test_helper'
class SwapWrestlersTest < ActionDispatch::IntegrationTest
def setup
@tournament = tournaments(:swap_wrestlers_tournament)
GenerateTournamentMatches.new(@tournament).generate
end
test "Wrestlers from different pools are swapped matches correctly" do
wrestler1 = wrestlers(:swap_wrestlers_wrestler_1)
wrestler2 = wrestlers(:swap_wrestlers_wrestler_2)
wrestler3 = wrestlers(:swap_wrestlers_wrestler_3)
wrestler4 = wrestlers(:swap_wrestlers_wrestler_4)
SwapWrestlers.new.swapWrestlers(wrestler1.id,wrestler2.id)
#Variable needs refreshed otherwise asserts fail
wrestler1 = Wrestler.find(54)
wrestler2 = Wrestler.find(55)
assert_not_empty wrestler1.matchAgainst(wrestler3)
assert_equal 2, wrestler1.pool
assert_equal 2, wrestler1.seed
assert_not_empty wrestler2.matchAgainst(wrestler4)
assert_equal 1, wrestler2.pool
assert_equal 1, wrestler2.seed
end
end