]> git.openstreetmap.org Git - rails.git/blob - test/abilities/guest_ability_test.rb
Merge remote-tracking branch 'upstream/pull/6787'
[rails.git] / test / abilities / guest_ability_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 class GuestAbilityTest < ActiveSupport::TestCase
6   test "search permissions for a guest" do
7     ability = Ability.new nil
8
9     [:create, :show].each do |action|
10       assert ability.can?(action, :search), "should be able to #{action} searches"
11     end
12   end
13
14   test "diary permissions for a guest" do
15     ability = Ability.new nil
16     [:index, :rss, :show].each do |action|
17       assert ability.can?(action, DiaryEntry), "should be able to #{action} DiaryEntries"
18     end
19
20     [:index].each do |action|
21       assert ability.can?(action, DiaryComment), "should be able to #{action} DiaryComments"
22     end
23
24     [:create, :edit, :subscribe, :unsubscribe, :hide, :unhide].each do |action|
25       assert ability.cannot?(action, DiaryEntry), "should not be able to #{action} DiaryEntries"
26     end
27
28     [:create, :hide, :unhide].each do |action|
29       assert ability.cannot?(action, DiaryComment), "should not be able to #{action} DiaryComments"
30     end
31   end
32
33   test "note permissions for a guest" do
34     ability = Ability.new nil
35
36     [:index].each do |action|
37       assert ability.can?(action, Note), "should be able to #{action} Notes"
38     end
39   end
40
41   test "user roles permissions for a guest" do
42     ability = Ability.new nil
43
44     [:create, :destroy].each do |action|
45       assert ability.cannot?(action, UserRole), "should not be able to #{action} UserRoles"
46     end
47   end
48 end