mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-31 11:35:45 +00:00
Added is_public to a tournament to hide lineups and brackets until you're ready to make it public
This commit is contained in:
@@ -17,6 +17,10 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
get :new, params: { tournament: @tournament.id }
|
||||
end
|
||||
|
||||
def get_show
|
||||
get :show, params: { id: @school.id }
|
||||
end
|
||||
|
||||
def post_update
|
||||
patch :update, params: { id: @school.id, school: {name: @school.name, tournament_id: @school.tournament_id} }
|
||||
end
|
||||
@@ -205,4 +209,85 @@ Some Guy
|
||||
redirect
|
||||
end
|
||||
|
||||
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
|
||||
test "logged in school delegate can get show page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_school_delegate
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in user cannot get show page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_non_owner
|
||||
get_show
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can get show page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_tournament_delegate
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament owner can get show page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_owner
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "non logged in user cannot get show page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
get_show
|
||||
redirect
|
||||
end
|
||||
|
||||
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
|
||||
test "logged in school delegate can get show page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_school_delegate
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in user can get show page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_non_owner
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can get show page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_tournament_delegate
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament owner can get show page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_owner
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "non logged in user can get show page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
get_show
|
||||
success
|
||||
end
|
||||
# END SHOW PAGE PERMISSIONS
|
||||
|
||||
end
|
||||
|
||||
@@ -14,6 +14,18 @@ class TournamentsControllerTest < ActionController::TestCase
|
||||
def post_update
|
||||
patch :update, params: { id: 1, tournament: {name: @tournament.name} }
|
||||
end
|
||||
|
||||
def get_bracket
|
||||
get :up_matches, params: { id: 1 }
|
||||
end
|
||||
|
||||
def get_all_brackets
|
||||
get :all_brackets, params: { id: 1 }
|
||||
end
|
||||
|
||||
def get_up_matches
|
||||
get :up_matches, params: { id: 1 }
|
||||
end
|
||||
|
||||
def get_edit
|
||||
get :edit, params: { id: 1 }
|
||||
@@ -211,6 +223,248 @@ class TournamentsControllerTest < ActionController::TestCase
|
||||
redirect
|
||||
end
|
||||
|
||||
# BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
|
||||
test "logged in school delegate cannot get bracket page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_school_delegate
|
||||
get_bracket
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in user cannot get bracket page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_non_owner
|
||||
get_bracket
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can get bracket page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_delegate
|
||||
get_bracket
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament owner can get bracket page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_owner
|
||||
get_bracket
|
||||
success
|
||||
end
|
||||
|
||||
test "non logged in user cannot get bracket page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
get_bracket
|
||||
redirect
|
||||
end
|
||||
|
||||
# BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
|
||||
test "logged in school delegate can get bracket page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_school_delegate
|
||||
get_bracket
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in user can get bracket page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_non_owner
|
||||
get_bracket
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can get bracket page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_delegate
|
||||
get_bracket
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament owner can get bracket page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_owner
|
||||
get_bracket
|
||||
success
|
||||
end
|
||||
|
||||
test "non logged in user can get bracket page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
get_bracket
|
||||
success
|
||||
end
|
||||
# END BRACKETS PAGE PERMISSIONS
|
||||
|
||||
# ALL BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
|
||||
test "logged in school delegate cannot get all brackets page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_school_delegate
|
||||
get_all_brackets
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in user cannot get all brackets page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_non_owner
|
||||
get_all_brackets
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can get all brackets page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_delegate
|
||||
get_all_brackets
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament owner can get all brackets page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_owner
|
||||
get_all_brackets
|
||||
success
|
||||
end
|
||||
|
||||
test "non logged in user cannot get all brackets page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
get_all_brackets
|
||||
redirect
|
||||
end
|
||||
|
||||
# ALL BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
|
||||
test "logged in school delegate can get all brackets page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_school_delegate
|
||||
get_all_brackets
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in user can get all brackets page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_non_owner
|
||||
get_all_brackets
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can get all brackets page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_delegate
|
||||
get_all_brackets
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament owner can get all brackets page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_owner
|
||||
get_all_brackets
|
||||
success
|
||||
end
|
||||
|
||||
test "non logged in user can get all brackets page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
get_all_brackets
|
||||
success
|
||||
end
|
||||
# END ALL BRACKETS PAGE PERMISSIONS
|
||||
|
||||
# UP MATCHES PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
|
||||
test "logged in school delegate cannot get up matches page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_school_delegate
|
||||
get_up_matches
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in user cannot get up matches page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_non_owner
|
||||
get_up_matches
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can get up matches page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_delegate
|
||||
get_up_matches
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament owner can get up matches page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_owner
|
||||
get_up_matches
|
||||
success
|
||||
end
|
||||
|
||||
test "non logged in user cannot get up matches page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
get_up_matches
|
||||
redirect
|
||||
end
|
||||
|
||||
# UP MATCHES PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
|
||||
test "logged in school delegate can get up matches page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_school_delegate
|
||||
get_up_matches
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in user can get up matches page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_non_owner
|
||||
get_up_matches
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can get up matches page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_delegate
|
||||
get_up_matches
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament owner can get up matches page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_owner
|
||||
get_up_matches
|
||||
success
|
||||
end
|
||||
|
||||
test "non logged in user can get up matches page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
get_up_matches
|
||||
success
|
||||
end
|
||||
# END UP MATCHES PAGE PERMISSIONS
|
||||
|
||||
#TESTS THAT NEED MATCHES PUT ABOVE THIS
|
||||
test "redirect up_matches if no matches" do
|
||||
|
||||
@@ -30,6 +30,10 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
get :edit, params: { id: @weight.id }
|
||||
end
|
||||
|
||||
def get_show
|
||||
get :show, params: { id: @weight.id }
|
||||
end
|
||||
|
||||
def get_pool_order
|
||||
post :pool_order, params: {pool_to_order: 1, id: @weight.id}
|
||||
end
|
||||
@@ -210,6 +214,87 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
redirect
|
||||
end
|
||||
|
||||
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
|
||||
test "logged in school delegate cannot get show page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_school_delegate
|
||||
get_show
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in user cannot get show page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_non_owner
|
||||
get_show
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can get show page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_tournament_delegate
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament owner can get show page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
sign_in_owner
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "non logged in user cannot get show page when tournament is not public" do
|
||||
@tournament.is_public = false
|
||||
@tournament.save
|
||||
get_show
|
||||
redirect
|
||||
end
|
||||
|
||||
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
|
||||
test "logged in school delegate can get show page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_school_delegate
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in user can get show page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_non_owner
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can get show page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_tournament_delegate
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament owner can get show page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
sign_in_owner
|
||||
get_show
|
||||
success
|
||||
end
|
||||
|
||||
test "non logged in user can get show page when tournament is public" do
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
get_show
|
||||
success
|
||||
end
|
||||
# END SHOW PAGE PERMISSIONS
|
||||
|
||||
test "view wegiht" do
|
||||
get :show, params: { id: 1 }
|
||||
success
|
||||
|
||||
3
test/fixtures/tournaments.yml
vendored
3
test/fixtures/tournaments.yml
vendored
@@ -8,4 +8,5 @@ one:
|
||||
director_email: jacob.wimer@gmail.com
|
||||
tournament_type: Pool to bracket
|
||||
user_id: 1
|
||||
date: 2015-12-30
|
||||
date: 2015-12-30
|
||||
is_public: true
|
||||
@@ -21,6 +21,7 @@ class ActiveSupport::TestCase
|
||||
@tournament.director_email= "test@test.com"
|
||||
@tournament.tournament_type = "Pool to bracket"
|
||||
@tournament.date = "2015-12-30"
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
@school = School.new
|
||||
@school.name = "Test"
|
||||
@@ -43,6 +44,7 @@ class ActiveSupport::TestCase
|
||||
@tournament.director_email= "test@test.com"
|
||||
@tournament.tournament_type = "Regular Double Elimination 1-6"
|
||||
@tournament.date = "2015-12-30"
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
@school = School.new
|
||||
@school.name = "Test"
|
||||
@@ -65,6 +67,7 @@ class ActiveSupport::TestCase
|
||||
@tournament.director_email= "test@test.com"
|
||||
@tournament.tournament_type = tournament_type
|
||||
@tournament.date = "2015-12-30"
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
@school = School.new
|
||||
@school.name = "Test"
|
||||
@@ -100,6 +103,7 @@ class ActiveSupport::TestCase
|
||||
@tournament.director_email= "test@test.com"
|
||||
@tournament.tournament_type = "Pool to bracket"
|
||||
@tournament.date = "2015-12-30"
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
|
||||
# First school
|
||||
|
||||
Reference in New Issue
Block a user