mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-21 06:22:00 +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)
|
sign_in users(:three)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_in_school_delegate
|
||||||
|
sign_in users(:four)
|
||||||
|
end
|
||||||
|
|
||||||
def success
|
def success
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
@@ -53,6 +57,12 @@ class MatchesControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "non logged in user should not get edit match page" do
|
||||||
get_edit
|
get_edit
|
||||||
redirect
|
redirect
|
||||||
@@ -69,6 +79,12 @@ class MatchesControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to '/static_pages/not_allowed'
|
assert_redirected_to '/static_pages/not_allowed'
|
||||||
end
|
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
|
test "logged in tournament delegate should get edit match page" do
|
||||||
sign_in_tournament_delegate
|
sign_in_tournament_delegate
|
||||||
get_edit
|
get_edit
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
sign_in users(:three)
|
sign_in users(:three)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_in_school_delegate
|
||||||
|
sign_in users(:four)
|
||||||
|
end
|
||||||
|
|
||||||
def success
|
def success
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
@@ -79,6 +83,12 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "non logged in user should not get edit mat page" do
|
||||||
get_edit
|
get_edit
|
||||||
redirect
|
redirect
|
||||||
@@ -95,6 +105,12 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "logged in tournament owner should post update mat" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
post_update
|
post_update
|
||||||
@@ -131,6 +147,14 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "logged in tournament owner can destroy a mat" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
destroy
|
destroy
|
||||||
@@ -149,12 +173,24 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "logged in user should not get show mat" do
|
||||||
sign_in_non_owner
|
sign_in_non_owner
|
||||||
show
|
show
|
||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "logged in tournament owner should get show mat" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
show
|
show
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ include Devise::TestHelpers
|
|||||||
sign_in users(:three)
|
sign_in users(:three)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_in_school_delegate
|
||||||
|
sign_in users(:four)
|
||||||
|
end
|
||||||
|
|
||||||
def success
|
def success
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
@@ -62,6 +66,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "logged in tournament owner can create custom weights" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
get :create_custom_weights, id: 1, customValue: 'hs'
|
get :create_custom_weights, id: 1, customValue: 'hs'
|
||||||
@@ -74,6 +84,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "logged in tournament owner can access weigh_ins" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
@@ -87,6 +103,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "logged in tournament owner can access weigh_in_weight" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
get :weigh_in, id: 1, weight: 1
|
get :weigh_in, id: 1, weight: 1
|
||||||
@@ -99,6 +121,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "logged in tournament owner can access post weigh_in_weight" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
post :weigh_in, id: 1, weight: 1, wrestler: @wrestlers
|
post :weigh_in, id: 1, weight: 1, wrestler: @wrestlers
|
||||||
@@ -110,6 +138,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "logged in tournament owner should get edit tournament page" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
@@ -123,6 +157,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "non logged in user should not get edit tournament page" do
|
||||||
get_edit
|
get_edit
|
||||||
redirect
|
redirect
|
||||||
@@ -139,6 +179,12 @@ include Devise::TestHelpers
|
|||||||
assert_redirected_to '/static_pages/not_allowed'
|
assert_redirected_to '/static_pages/not_allowed'
|
||||||
end
|
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
|
test "logged in tournament owner should post update tournament" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
post_update
|
post_update
|
||||||
@@ -158,6 +204,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
#TESTS THAT NEED MATCHES PUT ABOVE THIS
|
||||||
test "redirect up_matches if no matches" do
|
test "redirect up_matches if no matches" do
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
sign_in users(:three)
|
sign_in users(:three)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_in_school_delegate
|
||||||
|
sign_in users(:four)
|
||||||
|
end
|
||||||
|
|
||||||
def success
|
def success
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
@@ -67,6 +71,12 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "non logged in user should not get edit weight page" do
|
||||||
get_edit
|
get_edit
|
||||||
redirect
|
redirect
|
||||||
@@ -83,6 +93,12 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "logged in tournament owner should post update weight" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
post_update
|
post_update
|
||||||
@@ -119,6 +135,14 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
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
|
test "logged in tournament owner can destroy a weight" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
destroy
|
destroy
|
||||||
@@ -137,6 +161,12 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate not tournament owner cannot destroy weight" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
destroy
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "view wegiht" do
|
test "view wegiht" do
|
||||||
get :show, id: 1
|
get :show, id: 1
|
||||||
success
|
success
|
||||||
|
|||||||
Reference in New Issue
Block a user