mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-01 12:15:25 +00:00
Added logic to delegate tournament access
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user