1 # frozen_string_literal: true
5 class GuestAbilityTest < ActiveSupport::TestCase
6 test "search permissions for a guest" do
7 ability = Ability.new nil
9 [:create, :show].each do |action|
10 assert ability.can?(action, :search), "should be able to #{action} searches"
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"
20 [:index].each do |action|
21 assert ability.can?(action, DiaryComment), "should be able to #{action} DiaryComments"
24 [:create, :edit, :subscribe, :unsubscribe, :hide, :unhide].each do |action|
25 assert ability.cannot?(action, DiaryEntry), "should not be able to #{action} DiaryEntries"
28 [:create, :hide, :unhide].each do |action|
29 assert ability.cannot?(action, DiaryComment), "should not be able to #{action} DiaryComments"
33 test "note permissions for a guest" do
34 ability = Ability.new nil
36 [:index].each do |action|
37 assert ability.can?(action, Note), "should be able to #{action} Notes"
41 test "user roles permissions for a guest" do
42 ability = Ability.new nil
44 [:create, :destroy].each do |action|
45 assert ability.cannot?(action, UserRole), "should not be able to #{action} UserRoles"