1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14: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

@@ -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