1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-12 08:18:44 +00:00

Testing more controller actions

This commit is contained in:
2015-11-05 16:55:16 +00:00
parent 598d0314ba
commit 386d4c858b
2 changed files with 55 additions and 0 deletions

View File

@@ -16,6 +16,10 @@ class MatsControllerTest < ActionController::TestCase
def new def new
get :new, tournament: @tournament.id get :new, tournament: @tournament.id
end end
def show
get :show, id: 1
end
def post_update def post_update
patch :update, id: @mat.id, mat: {name: @mat.name, tournament_id: @mat.tournament_id} patch :update, id: @mat.id, mat: {name: @mat.name, tournament_id: @mat.tournament_id}
@@ -44,6 +48,14 @@ class MatsControllerTest < ActionController::TestCase
def redirect def redirect
assert_redirected_to '/static_pages/not_allowed' assert_redirected_to '/static_pages/not_allowed'
end 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 test "logged in tournament owner should get edit mat page" do
sign_in_owner sign_in_owner
@@ -106,4 +118,25 @@ class MatsControllerTest < ActionController::TestCase
destroy destroy
redirect redirect
end 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 end

View File

@@ -37,6 +37,13 @@ include Devise::TestHelpers
delete :destroy, id: 1 delete :destroy, id: 1
end 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 test "logged in tournament owner can generate matches" do
sign_in_owner sign_in_owner
@@ -134,6 +141,21 @@ include Devise::TestHelpers
destroy destroy
redirect redirect
end 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 end