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

Test all controllers for school delegate access

This commit is contained in:
2016-01-07 16:30:30 +00:00
parent 612902aa91
commit 1e9ca0d3b1
4 changed files with 135 additions and 1 deletions

View File

@@ -29,6 +29,10 @@ include Devise::TestHelpers
def sign_in_delegate
sign_in users(:three)
end
def sign_in_school_delegate
sign_in users(:four)
end
def success
assert_response :success
@@ -61,6 +65,12 @@ include Devise::TestHelpers
get :generate_matches, id: 1
redirect
end
test "logged in school delegate cannot generate matches" do
sign_in_school_delegate
get :generate_matches, id: 1
redirect
end
test "logged in tournament owner can create custom weights" do
sign_in_owner
@@ -73,6 +83,12 @@ include Devise::TestHelpers
get :create_custom_weights, id: 1, customValue: 'hs'
redirect
end
test "logged in school delegate cannot create custom weights" do
sign_in_school_delegate
get :create_custom_weights, id: 1, customValue: 'hs'
redirect
end
test "logged in tournament owner can access weigh_ins" do
@@ -86,6 +102,12 @@ include Devise::TestHelpers
get :weigh_in, id: 1
redirect
end
test "logged in school delegate cannot access weigh_ins" do
sign_in_school_delegate
get :weigh_in, id: 1
redirect
end
test "logged in tournament owner can access weigh_in_weight" do
sign_in_owner
@@ -99,6 +121,12 @@ include Devise::TestHelpers
redirect
end
test "logged in school delegate cannot access weigh_in_weight" do
sign_in_school_delegate
get :weigh_in_weight, id: 1, weight: 1
redirect
end
test "logged in tournament owner can access post weigh_in_weight" do
sign_in_owner
post :weigh_in, id: 1, weight: 1, wrestler: @wrestlers
@@ -109,6 +137,12 @@ include Devise::TestHelpers
post :weigh_in_weight, id: 1, weight: 1, wrestler: @wrestlers
redirect
end
test "logged in school delegate cannot access post weigh_in_weight" do
sign_in_school_delegate
post :weigh_in_weight, id: 1, weight: 1, wrestler: @wrestlers
redirect
end
test "logged in tournament owner should get edit tournament page" do
@@ -122,6 +156,12 @@ include Devise::TestHelpers
get_edit
redirect
end
test "logged in school delegate should not get edit tournament page if not owner" do
sign_in_school_delegate
get_edit
redirect
end
test "non logged in user should not get edit tournament page" do
get_edit
@@ -138,6 +178,12 @@ include Devise::TestHelpers
post_update
assert_redirected_to '/static_pages/not_allowed'
end
test "logged in school delegate should not post update tournament if not owner" do
sign_in_school_delegate
post_update
assert_redirected_to '/static_pages/not_allowed'
end
test "logged in tournament owner should post update tournament" do
sign_in_owner
@@ -158,6 +204,12 @@ include Devise::TestHelpers
redirect
end
test "logged in school delegate not tournament owner cannot destroy tournament" do
sign_in_school_delegate
destroy
redirect
end
#TESTS THAT NEED MATCHES PUT ABOVE THIS
test "redirect up_matches if no matches" do