mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-12 16:25:41 +00:00
Testing more controller actions
This commit is contained in:
@@ -17,6 +17,10 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
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}
|
||||||
end
|
end
|
||||||
@@ -45,6 +49,14 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
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
|
||||||
get_edit
|
get_edit
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -136,4 +143,19 @@ include Devise::TestHelpers
|
|||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user