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

Added baumspage roster importer

This commit is contained in:
2019-01-10 13:25:31 +00:00
parent 046b48370e
commit 31323593c9
9 changed files with 159 additions and 3 deletions

View File

@@ -53,6 +53,21 @@ class SchoolsControllerTest < ActionController::TestCase
assert_redirected_to '/static_pages/not_allowed'
end
def baums_import
baums_text = "***** 2019-01-09 13:36:50 *****
Some School
Some Guy
106,,,,,,,,,
113,Guy,Another,9,,,,,5,7
120,Guy2,Another,9,,,,,0,0
126,Guy3,Another,10,,,,5@120,2,2
******* Extra Wrestlers *******
120,Guy4,Another,10,0,3
126,Guy5,Another,9,,"
post :import_baumspage_roster, params: { id: @school.id, school: { baums_text: baums_text } }
end
test "logged in tournament owner should get edit school page" do
sign_in_owner
get_edit
@@ -172,4 +187,22 @@ class SchoolsControllerTest < ActionController::TestCase
success
end
test "logged in school delegate can import baumspage roster" do
sign_in_school_delegate
baums_import
assert_redirected_to "/schools/#{@school.id}"
end
test "logged in tournament delegate can import baumspage roster" do
sign_in_tournament_delegate
baums_import
assert_redirected_to "/schools/#{@school.id}"
end
test "logged in user cannot import baumspage roster" do
sign_in_non_owner
baums_import
redirect
end
end

View File

@@ -0,0 +1,28 @@
require 'test_helper'
class BaumspageImporterTest < ActionDispatch::IntegrationTest
def setup
@school = School.find(1)
@baums_text = "***** 2019-01-09 13:36:50 *****
Some School
Some Guy
106,,,,,,,,,
113,Guy,Another,9,,,,,5,7
120,Guy2,Another,9,,,,,0,0
126,Guy3,Another,10,,,,5@120,2,2
******* Extra Wrestlers *******
120,Guy4,Another,10,0,3
126,Guy5,Another,9,,"
end
test "5 wrestlers get created with Baumspage Importer" do
BaumspageRosterImport.new(@school,@baums_text).import_roster
assert @school.reload.wrestlers.size == 5
extras = @school.wrestlers.select{|w| w.extra == true}
assert extras.size == 2
guy = @school.wrestlers.select{|w| w.name == "Another Guy"}.first
assert guy.season_win == 5
assert guy.season_loss == 7
end
end