]> git.openstreetmap.org Git - rails.git/blob - test/abilities/user_ability_test.rb
Merge remote-tracking branch 'upstream/pull/6787'
[rails.git] / test / abilities / user_ability_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 class UserAbilityTest < ActiveSupport::TestCase
6   test "Diary permissions" do
7     ability = Ability.new create(:user)
8
9     [:index, :rss, :show, :create, :edit, :subscribe, :unsubscribe].each do |action|
10       assert ability.can?(action, DiaryEntry), "should be able to #{action} DiaryEntries"
11     end
12
13     [:index, :create].each do |action|
14       assert ability.can?(action, DiaryComment), "should be able to #{action} DiaryComments"
15     end
16
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"
20     end
21
22     [:index, :show, :resolve, :ignore, :reopen].each do |action|
23       assert ability.cannot?(action, Issue), "should not be able to #{action} Issues"
24     end
25   end
26 end