mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Added logic to delegate tournament access
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class AdminControllerTest < ActionController::TestCase
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
||||
@@ -24,6 +24,10 @@ class MatchesControllerTest < ActionController::TestCase
|
||||
def sign_in_non_owner
|
||||
sign_in users(:two)
|
||||
end
|
||||
|
||||
def sign_in_tournament_delegate
|
||||
sign_in users(:three)
|
||||
end
|
||||
|
||||
def success
|
||||
assert_response :success
|
||||
@@ -65,11 +69,16 @@ class MatchesControllerTest < ActionController::TestCase
|
||||
assert_redirected_to '/static_pages/not_allowed'
|
||||
end
|
||||
|
||||
test "logged in tournament owner should post update match" do
|
||||
sign_in_owner
|
||||
test "logged in tournament delegate should get edit match page" do
|
||||
sign_in_tournament_delegate
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should post update match" do
|
||||
sign_in_tournament_delegate
|
||||
post_update
|
||||
assert_redirected_to mat_path(1)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -40,6 +40,10 @@ class MatsControllerTest < ActionController::TestCase
|
||||
def sign_in_non_owner
|
||||
sign_in users(:two)
|
||||
end
|
||||
|
||||
def sign_in_tournament_delegate
|
||||
sign_in users(:three)
|
||||
end
|
||||
|
||||
def success
|
||||
assert_response :success
|
||||
@@ -62,6 +66,12 @@ class MatsControllerTest < ActionController::TestCase
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should get edit mat page" do
|
||||
sign_in_tournament_delegate
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in user should not get edit mat page if not owner" do
|
||||
sign_in_non_owner
|
||||
@@ -90,6 +100,12 @@ class MatsControllerTest < ActionController::TestCase
|
||||
post_update
|
||||
assert_redirected_to tournament_path(@mat.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should post update mat" do
|
||||
sign_in_tournament_delegate
|
||||
post_update
|
||||
assert_redirected_to tournament_path(@mat.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in tournament owner can create a new mat" do
|
||||
sign_in_owner
|
||||
@@ -98,6 +114,14 @@ class MatsControllerTest < ActionController::TestCase
|
||||
create
|
||||
assert_redirected_to tournament_path(@mat.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can create a new mat" do
|
||||
sign_in_tournament_delegate
|
||||
new
|
||||
success
|
||||
create
|
||||
assert_redirected_to tournament_path(@mat.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in user not tournament owner cannot create a mat" do
|
||||
sign_in_non_owner
|
||||
@@ -112,6 +136,12 @@ class MatsControllerTest < ActionController::TestCase
|
||||
destroy
|
||||
assert_redirected_to tournament_path(@tournament.id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can destroy a mat" do
|
||||
sign_in_tournament_delegate
|
||||
destroy
|
||||
assert_redirected_to tournament_path(@tournament.id)
|
||||
end
|
||||
|
||||
test "logged in user not tournament owner cannot destroy mat" do
|
||||
sign_in_non_owner
|
||||
@@ -130,6 +160,12 @@ class MatsControllerTest < ActionController::TestCase
|
||||
show
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should get show mat" do
|
||||
sign_in_tournament_delegate
|
||||
show
|
||||
success
|
||||
end
|
||||
|
||||
|
||||
#TESTS THAT NEED MATCHES PUT ABOVE THIS
|
||||
|
||||
@@ -36,6 +36,10 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
def sign_in_non_owner
|
||||
sign_in users(:two)
|
||||
end
|
||||
|
||||
def sign_in_tournament_delegate
|
||||
sign_in users(:three)
|
||||
end
|
||||
|
||||
def success
|
||||
assert_response :success
|
||||
@@ -50,6 +54,12 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should get edit school page" do
|
||||
sign_in_tournament_delegate
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in user should not get edit school page if not owner" do
|
||||
sign_in_non_owner
|
||||
@@ -78,6 +88,12 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
post_update
|
||||
assert_redirected_to tournament_path(@school.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should post update school" do
|
||||
sign_in_tournament_delegate
|
||||
post_update
|
||||
assert_redirected_to tournament_path(@school.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in tournament owner can create a new school" do
|
||||
sign_in_owner
|
||||
@@ -86,6 +102,14 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
create
|
||||
assert_redirected_to tournament_path(@school.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can create a new school" do
|
||||
sign_in_tournament_delegate
|
||||
new
|
||||
success
|
||||
create
|
||||
assert_redirected_to tournament_path(@school.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in user not tournament owner cannot create a school" do
|
||||
sign_in_non_owner
|
||||
@@ -100,6 +124,12 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
destroy
|
||||
assert_redirected_to tournament_path(@tournament.id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can destroy a school" do
|
||||
sign_in_tournament_delegate
|
||||
destroy
|
||||
assert_redirected_to tournament_path(@tournament.id)
|
||||
end
|
||||
|
||||
test "logged in user not tournament owner cannot destroy school" do
|
||||
sign_in_non_owner
|
||||
|
||||
@@ -25,6 +25,10 @@ include Devise::TestHelpers
|
||||
def sign_in_non_owner
|
||||
sign_in users(:two)
|
||||
end
|
||||
|
||||
def sign_in_delegate
|
||||
sign_in users(:three)
|
||||
end
|
||||
|
||||
def success
|
||||
assert_response :success
|
||||
@@ -169,5 +173,53 @@ include Devise::TestHelpers
|
||||
get :bracket, id: 1, weight: 1
|
||||
no_matches
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can generate matches" do
|
||||
sign_in_delegate
|
||||
get :generate_matches, id: 1
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can create custom weights" do
|
||||
sign_in_delegate
|
||||
get :create_custom_weights, id: 1, customValue: 'hs'
|
||||
assert_redirected_to '/tournaments/1'
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can access weigh_ins" do
|
||||
sign_in_delegate
|
||||
get :weigh_in, id: 1
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can access weigh_in_weight" do
|
||||
sign_in_delegate
|
||||
get :weigh_in, id: 1, weight: 1
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should get edit tournament page" do
|
||||
sign_in_delegate
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can access post weigh_in_weight" do
|
||||
sign_in_delegate
|
||||
post :weigh_in, id: 1, weight: 1, wrestler: @wrestlers
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should post update tournament" do
|
||||
sign_in_delegate
|
||||
post_update
|
||||
assert_redirected_to tournament_path(1)
|
||||
end
|
||||
|
||||
|
||||
test "logged in tournament delegate cannot destroy a tournament" do
|
||||
sign_in_delegate
|
||||
destroy
|
||||
redirect
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -36,6 +36,10 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
def sign_in_non_owner
|
||||
sign_in users(:two)
|
||||
end
|
||||
|
||||
def sign_in_tournament_delegate
|
||||
sign_in users(:three)
|
||||
end
|
||||
|
||||
def success
|
||||
assert_response :success
|
||||
@@ -50,6 +54,12 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should get edit weight page" do
|
||||
sign_in_tournament_delegate
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in user should not get edit weight page if not owner" do
|
||||
sign_in_non_owner
|
||||
@@ -78,6 +88,12 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
post_update
|
||||
assert_redirected_to tournament_path(@weight.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should post update weight" do
|
||||
sign_in_tournament_delegate
|
||||
post_update
|
||||
assert_redirected_to tournament_path(@weight.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in tournament owner can create a new weight" do
|
||||
sign_in_owner
|
||||
@@ -86,6 +102,14 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
create
|
||||
assert_redirected_to tournament_path(@weight.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can create a new weight" do
|
||||
sign_in_tournament_delegate
|
||||
new
|
||||
success
|
||||
create
|
||||
assert_redirected_to tournament_path(@weight.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in user not tournament owner cannot create a weight" do
|
||||
sign_in_non_owner
|
||||
@@ -100,6 +124,12 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
destroy
|
||||
assert_redirected_to tournament_path(@tournament.id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can destroy a weight" do
|
||||
sign_in_tournament_delegate
|
||||
destroy
|
||||
assert_redirected_to tournament_path(@tournament.id)
|
||||
end
|
||||
|
||||
test "logged in user not tournament owner cannot destroy weight" do
|
||||
sign_in_non_owner
|
||||
|
||||
@@ -37,6 +37,10 @@ class WrestlersControllerTest < ActionController::TestCase
|
||||
def sign_in_non_owner
|
||||
sign_in users(:two)
|
||||
end
|
||||
|
||||
def sign_in_tournament_delegate
|
||||
sign_in users(:three)
|
||||
end
|
||||
|
||||
def success
|
||||
assert_response :success
|
||||
@@ -51,6 +55,12 @@ class WrestlersControllerTest < ActionController::TestCase
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should get edit wrestler page" do
|
||||
sign_in_tournament_delegate
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in user should not get edit wrestler page if not owner" do
|
||||
sign_in_non_owner
|
||||
@@ -79,6 +89,12 @@ class WrestlersControllerTest < ActionController::TestCase
|
||||
post_update
|
||||
assert_redirected_to school_path(@school.id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate should post update wrestler" do
|
||||
sign_in_tournament_delegate
|
||||
post_update
|
||||
assert_redirected_to school_path(@school.id)
|
||||
end
|
||||
|
||||
test "logged in tournament owner can create a new wrestler" do
|
||||
sign_in_owner
|
||||
@@ -87,6 +103,14 @@ class WrestlersControllerTest < ActionController::TestCase
|
||||
create
|
||||
assert_redirected_to school_path(@school.id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can create a new wrestler" do
|
||||
sign_in_tournament_delegate
|
||||
new
|
||||
success
|
||||
create
|
||||
assert_redirected_to school_path(@school.id)
|
||||
end
|
||||
|
||||
test "logged in user not tournament owner cannot create a wrestler" do
|
||||
sign_in_non_owner
|
||||
@@ -101,6 +125,12 @@ class WrestlersControllerTest < ActionController::TestCase
|
||||
destroy
|
||||
assert_redirected_to school_path(@school.id)
|
||||
end
|
||||
|
||||
test "logged in tournament delegate can destroy a wrestler" do
|
||||
sign_in_tournament_delegate
|
||||
destroy
|
||||
assert_redirected_to school_path(@school.id)
|
||||
end
|
||||
|
||||
test "logged in user not tournament owner cannot destroy wrestler" do
|
||||
sign_in_non_owner
|
||||
|
||||
9
test/fixtures/school_delegates.yml
vendored
Normal file
9
test/fixtures/school_delegates.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# one:
|
||||
# user_id: 1
|
||||
# school_id: 1
|
||||
|
||||
# two:
|
||||
# user_id: 1
|
||||
# school_id: 1
|
||||
13
test/fixtures/tournament_delegates.yml
vendored
Normal file
13
test/fixtures/tournament_delegates.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# one:
|
||||
# user_id: 1
|
||||
# tournament_id: 1
|
||||
|
||||
# two:
|
||||
# user_id: 1
|
||||
# tournament_id: 1
|
||||
|
||||
one:
|
||||
user_id: 3
|
||||
tournament_id: 1
|
||||
4
test/fixtures/users.yml
vendored
4
test/fixtures/users.yml
vendored
@@ -15,3 +15,7 @@ one:
|
||||
two:
|
||||
email: test2@test.com
|
||||
id: 2
|
||||
|
||||
three:
|
||||
email: test3@test.com
|
||||
id: 3
|
||||
|
||||
7
test/models/school_delegate_test.rb
Normal file
7
test/models/school_delegate_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class SchoolDelegateTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/models/tournament_delegate_test.rb
Normal file
7
test/models/tournament_delegate_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TournamentDelegateTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user