Skip to content

Commit 6d08c5f

Browse files
authored
Merge pull request #172 from MITLibraries/tco-133-permissions-updates
Authenticated users terms and playground access
2 parents 1c8ce6d + e21b01a commit 6d08c5f

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

app/models/ability.rb

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ def initialize(user)
2323
# Allow all authenticated users to view reports
2424
can :view, :report
2525

26+
# All users can see search events and terms
27+
can %w[index show], :search_event
28+
can %i[read view], SearchEvent
29+
can %w[index show], :term
30+
can %i[read view], Term
31+
32+
# All users can use playground
33+
can :view, :playground
34+
2635
# Create manual confirmation
2736
can :manage, :confirmations
2837
can :manage, Confirmation

test/controllers/static_controller_test.rb

+2-5
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ class StaticControllerTest < ActionDispatch::IntegrationTest
2626
assert_response :success
2727
end
2828

29-
test 'playground url is not accessible to basic users when authenticated' do
29+
test 'playground url is accessible to basic users when authenticated' do
3030
sign_in users(:basic)
3131

3232
get '/playground'
3333

34-
assert_redirected_to '/'
35-
follow_redirect!
36-
37-
assert_select 'div.alert', text: 'Not authorized.', count: 1
34+
assert_response :success
3835
end
3936
end

test/integration/admin_dashboard_test.rb

+3-6
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ def teardown
2121
assert_select 'div.alert', text: 'Please sign in to continue', count: 1
2222
end
2323

24-
test 'authenticated users without admin status still cannot access admin area' do
24+
test 'authenticated users without admin status can access admin area' do
2525
mock_auth(users(:basic))
2626
get '/admin'
2727

28-
assert_response :redirect
29-
follow_redirect!
30-
31-
assert_equal '/', path
32-
assert_select 'div.alert', text: 'Not authorized', count: 1
28+
assert_response :ok
29+
assert_equal '/admin', path
3330
end
3431

3532
test 'admin users can access admin area' do

0 commit comments

Comments
 (0)