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:
5
test/fixtures/schools.yml
vendored
5
test/fixtures/schools.yml
vendored
@@ -15,3 +15,8 @@ three:
|
||||
name: Central Crossing
|
||||
tournament_id: 2
|
||||
|
||||
swap_wrestlers:
|
||||
id: 4
|
||||
name: Central Crossing
|
||||
tournament_id: 3
|
||||
|
||||
|
||||
10
test/fixtures/tournaments.yml
vendored
10
test/fixtures/tournaments.yml
vendored
@@ -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
|
||||
|
||||
5
test/fixtures/weights.yml
vendored
5
test/fixtures/weights.yml
vendored
@@ -30,3 +30,8 @@ six:
|
||||
id: 6
|
||||
max: 285
|
||||
tournament_id: 1
|
||||
|
||||
swap_wrestlers:
|
||||
id: 7
|
||||
max: 138
|
||||
tournament_id: 3
|
||||
|
||||
84
test/fixtures/wrestlers.yml
vendored
84
test/fixtures/wrestlers.yml
vendored
@@ -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:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
28
test/integration/swap_wrestlers_test.rb
Normal file
28
test/integration/swap_wrestlers_test.rb
Normal 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
|
||||
Reference in New Issue
Block a user