1 # frozen_string_literal: true
5 class UserAbilityTest < ActiveSupport::TestCase
6 test "Diary permissions" do
7 ability = Ability.new create(:user)
9 [:index, :rss, :show, :create, :edit, :subscribe, :unsubscribe].each do |action|
10 assert ability.can?(action, DiaryEntry), "should be able to #{action} DiaryEntries"
13 [:index, :create].each do |action|
14 assert ability.can?(action, DiaryComment), "should be able to #{action} DiaryComments"
17 [:hide, :unhide].each do |action|
18 assert ability.cannot?(action, DiaryEntry), "should not be able to #{action} DiaryEntries"
19 assert ability.cannot?(action, DiaryComment), "should not be able to #{action} DiaryComment"
22 [:index, :show, :resolve, :ignore, :reopen].each do |action|
23 assert ability.cannot?(action, Issue), "should not be able to #{action} Issues"