From 386d4c858b39355483af96e2fc17b678ef0a01f9 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 5 Nov 2015 16:55:16 +0000 Subject: [PATCH] Testing more controller actions --- test/controllers/mats_controller_test.rb | 33 +++++++++++++++++++ .../tournaments_controller_test.rb | 22 +++++++++++++ 2 files changed, 55 insertions(+) diff --git a/test/controllers/mats_controller_test.rb b/test/controllers/mats_controller_test.rb index d67b2f5..0bf557f 100644 --- a/test/controllers/mats_controller_test.rb +++ b/test/controllers/mats_controller_test.rb @@ -16,6 +16,10 @@ class MatsControllerTest < ActionController::TestCase def new get :new, tournament: @tournament.id end + + def show + get :show, id: 1 + end def post_update patch :update, id: @mat.id, mat: {name: @mat.name, tournament_id: @mat.tournament_id} @@ -44,6 +48,14 @@ class MatsControllerTest < ActionController::TestCase def redirect assert_redirected_to '/static_pages/not_allowed' end + + def no_matches + assert_redirected_to "/tournaments/#{@tournament.id}/no_matches" + end + + def wipe + @tournament.destroyAllMatches + end test "logged in tournament owner should get edit mat page" do sign_in_owner @@ -106,4 +118,25 @@ class MatsControllerTest < ActionController::TestCase destroy redirect end + + test "logged in user should not get show mat" do + sign_in_non_owner + show + redirect + end + + test "logged in tournament owner should get show mat" do + sign_in_owner + show + success + end + + +#TESTS THAT NEED MATCHES PUT ABOVE THIS + test "redirect show if no matches" do + sign_in_owner + wipe + show + no_matches + end end diff --git a/test/controllers/tournaments_controller_test.rb b/test/controllers/tournaments_controller_test.rb index 143df94..bda742e 100644 --- a/test/controllers/tournaments_controller_test.rb +++ b/test/controllers/tournaments_controller_test.rb @@ -37,6 +37,13 @@ include Devise::TestHelpers delete :destroy, id: 1 end + def no_matches + assert_redirected_to "/tournaments/#{@tournament.id}/no_matches" + end + + def wipe + @tournament.destroyAllMatches + end test "logged in tournament owner can generate matches" do sign_in_owner @@ -134,6 +141,21 @@ include Devise::TestHelpers destroy redirect end + +#TESTS THAT NEED MATCHES PUT ABOVE THIS + test "redirect up_matches if no matches" do + sign_in_owner + wipe + get :up_matches, id: 1 + no_matches + end + + test "redirect bracket if no matches" do + sign_in_owner + wipe + get :bracket, id: 1, weight: 1 + no_matches + end end