mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-05-17 19:05:06 +00:00
Test all controllers for school delegate access
This commit is contained in:
@@ -29,6 +29,10 @@ class MatchesControllerTest < ActionController::TestCase
|
||||
sign_in users(:three)
|
||||
end
|
||||
|
||||
def sign_in_school_delegate
|
||||
sign_in users(:four)
|
||||
end
|
||||
|
||||
def success
|
||||
assert_response :success
|
||||
end
|
||||
@@ -53,6 +57,12 @@ class MatchesControllerTest < ActionController::TestCase
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged school delegate should not get edit match page if not owner" do
|
||||
sign_in_school_delegate
|
||||
get_edit
|
||||
redirect
|
||||
end
|
||||
|
||||
test "non logged in user should not get edit match page" do
|
||||
get_edit
|
||||
redirect
|
||||
@@ -69,6 +79,12 @@ class MatchesControllerTest < ActionController::TestCase
|
||||
assert_redirected_to '/static_pages/not_allowed'
|
||||
end
|
||||
|
||||
test "logged school delegate should not post update match if not owner" do
|
||||
sign_in_school_delegate
|
||||
post_update
|
||||
assert_redirected_to '/static_pages/not_allowed'
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should get edit match page" do
|
||||
sign_in_tournament_delegate
|
||||
get_edit
|
||||
|
||||
@@ -45,6 +45,10 @@ class MatsControllerTest < ActionController::TestCase
|
||||
sign_in users(:three)
|
||||
end
|
||||
|
||||
def sign_in_school_delegate
|
||||
sign_in users(:four)
|
||||
end
|
||||
|
||||
def success
|
||||
assert_response :success
|
||||
end
|
||||
@@ -79,6 +83,12 @@ class MatsControllerTest < ActionController::TestCase
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged school delegate should not get edit mat page if not owner" do
|
||||
sign_in_school_delegate
|
||||
get_edit
|
||||
redirect
|
||||
end
|
||||
|
||||
test "non logged in user should not get edit mat page" do
|
||||
get_edit
|
||||
redirect
|
||||
@@ -95,6 +105,12 @@ class MatsControllerTest < ActionController::TestCase
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged school delegate should not post update mat if not owner" do
|
||||
sign_in_school_delegate
|
||||
post_update
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in tournament owner should post update mat" do
|
||||
sign_in_owner
|
||||
post_update
|
||||
@@ -131,6 +147,14 @@ class MatsControllerTest < ActionController::TestCase
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged school delegate not tournament owner cannot create a mat" do
|
||||
sign_in_school_delegate
|
||||
new
|
||||
redirect
|
||||
create
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in tournament owner can destroy a mat" do
|
||||
sign_in_owner
|
||||
destroy
|
||||
@@ -149,12 +173,24 @@ class MatsControllerTest < ActionController::TestCase
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged school delegate not tournament owner cannot destroy mat" do
|
||||
sign_in_school_delegate
|
||||
destroy
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in user should not get show mat" do
|
||||
sign_in_non_owner
|
||||
show
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged school delegate should not get show mat" do
|
||||
sign_in_school_delegate
|
||||
show
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in tournament owner should get show mat" do
|
||||
sign_in_owner
|
||||
show
|
||||
|
||||
@@ -30,6 +30,10 @@ include Devise::TestHelpers
|
||||
sign_in users(:three)
|
||||
end
|
||||
|
||||
def sign_in_school_delegate
|
||||
sign_in users(:four)
|
||||
end
|
||||
|
||||
def success
|
||||
assert_response :success
|
||||
end
|
||||
@@ -62,6 +66,12 @@ include Devise::TestHelpers
|
||||
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
|
||||
get :create_custom_weights, id: 1, customValue: 'hs'
|
||||
@@ -74,6 +84,12 @@ include Devise::TestHelpers
|
||||
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
|
||||
sign_in_owner
|
||||
@@ -87,6 +103,12 @@ include Devise::TestHelpers
|
||||
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
|
||||
get :weigh_in, id: 1, weight: 1
|
||||
@@ -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
|
||||
@@ -110,6 +138,12 @@ include Devise::TestHelpers
|
||||
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
|
||||
sign_in_owner
|
||||
@@ -123,6 +157,12 @@ include Devise::TestHelpers
|
||||
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
|
||||
redirect
|
||||
@@ -139,6 +179,12 @@ include Devise::TestHelpers
|
||||
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
|
||||
post_update
|
||||
@@ -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
|
||||
|
||||
@@ -41,6 +41,10 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
sign_in users(:three)
|
||||
end
|
||||
|
||||
def sign_in_school_delegate
|
||||
sign_in users(:four)
|
||||
end
|
||||
|
||||
def success
|
||||
assert_response :success
|
||||
end
|
||||
@@ -67,6 +71,12 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged school delegate should not get edit weight page if not owner" do
|
||||
sign_in_school_delegate
|
||||
get_edit
|
||||
redirect
|
||||
end
|
||||
|
||||
test "non logged in user should not get edit weight page" do
|
||||
get_edit
|
||||
redirect
|
||||
@@ -83,6 +93,12 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged school delegate should not post update weight if not owner" do
|
||||
sign_in_school_delegate
|
||||
post_update
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in tournament owner should post update weight" do
|
||||
sign_in_owner
|
||||
post_update
|
||||
@@ -119,6 +135,14 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged school delegate not tournament owner cannot create a weight" do
|
||||
sign_in_school_delegate
|
||||
new
|
||||
redirect
|
||||
create
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in tournament owner can destroy a weight" do
|
||||
sign_in_owner
|
||||
destroy
|
||||
@@ -137,6 +161,12 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged school delegate not tournament owner cannot destroy weight" do
|
||||
sign_in_school_delegate
|
||||
destroy
|
||||
redirect
|
||||
end
|
||||
|
||||
test "view wegiht" do
|
||||
get :show, id: 1
|
||||
success
|
||||
|
||||
Reference in New Issue
Block a user