1
0
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:
2016-01-07 16:08:46 +00:00
parent cbf95ea07b
commit 612902aa91
10 changed files with 92 additions and 12 deletions

View File

@@ -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

View File

@@ -41,6 +41,10 @@ class WrestlersControllerTest < 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
@@ -61,6 +65,12 @@ class WrestlersControllerTest < ActionController::TestCase
get_edit
success
end
test "logged in school delegate should get edit wrestler page" do
sign_in_school_delegate
get_edit
success
end
test "logged in user should not get edit wrestler page if not owner" do
sign_in_non_owner
@@ -95,6 +105,12 @@ class WrestlersControllerTest < ActionController::TestCase
post_update
assert_redirected_to school_path(@school.id)
end
test "logged in school delegate should post update wrestler" do
sign_in_school_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
@@ -111,6 +127,14 @@ class WrestlersControllerTest < ActionController::TestCase
create
assert_redirected_to school_path(@school.id)
end
test "logged in school delegate can create a new wrestler" do
sign_in_school_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
@@ -131,6 +155,12 @@ class WrestlersControllerTest < ActionController::TestCase
destroy
assert_redirected_to school_path(@school.id)
end
test "logged in school delegate can destroy a wrestler" do
sign_in_school_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