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

Fixed redirect for match editing and added controller tests. Added wrestler school name to match edit form. Added authorization tests to all matches page.

This commit is contained in:
2019-01-23 19:22:55 +00:00
parent bb8ec92bf0
commit b001445090
9 changed files with 52 additions and 21 deletions

View File

@@ -4,9 +4,10 @@ class MatsControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
setup do
@tournament = Tournament.find(1)
@tournament = Tournament.find(1)
# @tournament.generateMatchups
@mat = mats(:one)
@match = Match.where("tournament_id = ? and mat_id = ?",1,1).first
@mat = mats(:one)
end
def create
@@ -65,6 +66,14 @@ class MatsControllerTest < ActionController::TestCase
@tournament.destroy_all_matches
end
def post_match_update_from_mat_show
get :show, params: { id: @mat.id }
old_controller = @controller
@controller = MatchesController.new
patch :update, params: { id: @match.id, match: {tournament_id: 1, mat_id: @mat.id} }
@controller = old_controller
end
test "logged in tournament owner should get edit mat page" do
sign_in_owner
get_edit
@@ -203,7 +212,11 @@ class MatsControllerTest < ActionController::TestCase
success
end
test "redirect to mat show when posting a match from mat show" do
sign_in_owner
post_match_update_from_mat_show
assert_redirected_to "/mats/#{@mat.id}"
end
#TESTS THAT NEED MATCHES PUT ABOVE THIS
test "redirect show if no matches" do
sign_in_owner