mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
School delegates permissions are working
This commit is contained in:
@@ -40,6 +40,10 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
def sign_in_tournament_delegate
|
||||
sign_in users(:three)
|
||||
end
|
||||
|
||||
def sign_in_school_delegate
|
||||
sign_in users(:four)
|
||||
end
|
||||
|
||||
def success
|
||||
assert_response :success
|
||||
@@ -60,6 +64,12 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in school delegate should get edit school page" do
|
||||
sign_in_school_delegate
|
||||
get_edit
|
||||
success
|
||||
end
|
||||
|
||||
test "logged in user should not get edit school page if not owner" do
|
||||
sign_in_non_owner
|
||||
@@ -94,6 +104,12 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
post_update
|
||||
assert_redirected_to tournament_path(@school.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in school delegate should post update school" do
|
||||
sign_in_school_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
|
||||
@@ -110,6 +126,14 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
create
|
||||
assert_redirected_to tournament_path(@school.tournament_id)
|
||||
end
|
||||
|
||||
test "logged in school delegate cannot create a new school" do
|
||||
sign_in_school_delegate
|
||||
new
|
||||
redirect
|
||||
create
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in user not tournament owner cannot create a school" do
|
||||
sign_in_non_owner
|
||||
@@ -130,6 +154,12 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
destroy
|
||||
assert_redirected_to tournament_path(@tournament.id)
|
||||
end
|
||||
|
||||
test "logged in school delegate can destroy a school" do
|
||||
sign_in_school_delegate
|
||||
destroy
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in user not tournament owner cannot destroy school" do
|
||||
sign_in_non_owner
|
||||
|
||||
Reference in New Issue
Block a user