Skip to content

Commit

Permalink
Test learning path curator role privileges
Browse files Browse the repository at this point in the history
  • Loading branch information
fbacall committed Aug 30, 2024
1 parent 4f946dc commit 1340468
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
24 changes: 21 additions & 3 deletions test/controllers/learning_paths_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class LearningPathsControllerTest < ActionController::TestCase
get :new
assert_response :success

sign_in users(:learning_path_curator)
get :new
assert_response :success

sign_in users(:admin)
get :new
assert_response :success
Expand All @@ -82,6 +86,12 @@ class LearningPathsControllerTest < ActionController::TestCase
assert_response :success
end

test 'should get edit for learning path curator' do
sign_in users(:learning_path_curator)
get :edit, params: { id: @learning_path }
assert_response :success
end

test 'should get edit for admin' do
#Owner of learning_path logged in = SUCCESS
sign_in users(:admin)
Expand All @@ -105,6 +115,14 @@ class LearningPathsControllerTest < ActionController::TestCase
assert_redirected_to learning_path_path(assigns(:learning_path))
end

test 'should create learning_path for learning_path_curator' do
sign_in users(:learning_path_curator)
assert_difference('LearningPath.count') do
post :create, params: { learning_path: { title: @learning_path.title, description: @learning_path.description } }
end
assert_redirected_to learning_path_path(assigns(:learning_path))
end

test 'should create learning_path for admin' do
sign_in users(:admin)
assert_difference('LearningPath.count') do
Expand Down Expand Up @@ -339,8 +357,8 @@ class LearningPathsControllerTest < ActionController::TestCase
assert_select 'a.btn[href=?]', learning_path_path(@learning_path), count: 0 #No Edit
end

test 'show action buttons when curator' do
sign_in users(:curator)
test 'show action buttons when learning_path_curator' do
sign_in users(:learning_path_curator)

get :show, params: { id: @learning_path }

Expand All @@ -365,7 +383,7 @@ class LearningPathsControllerTest < ActionController::TestCase
end

test 'should allow access to private learning_paths if privileged' do
sign_in users(:curator)
sign_in users(:learning_path_curator)
get :show, params: { id: learning_paths(:in_development_learning_path) }
assert_response :success
end
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ basic_user:
unverified_user: # Content requires approval before being visible
name: unverified_user
title: New user

learning_path_curator:
name: learning_path_curator
title: Learning path curator
8 changes: 7 additions & 1 deletion test/fixtures/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ banned_user:
role: user
authentication_token: <%= Devise.friendly_token %>


shadowbanned_user:
username: Chad O'Band
email: '[email protected]'
Expand Down Expand Up @@ -151,3 +150,10 @@ upcase_username_and_email:
email: '[email protected]'
encrypted_password: <%= Devise::Encryptor.digest(User, 'private') %>
confirmed_at: <%= Time.zone.now %>

learning_path_curator:
username: 'lp_cur8r'
email: '[email protected]'
encrypted_password: 'learning_paths_curator_encrypted_password'
confirmed_at: <%= Time.zone.now %>
role: learning_path_curator

0 comments on commit 1340468

Please sign in to comment.