1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +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
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