]> git.openstreetmap.org Git - rails.git/blob - test/abilities/user_ability_test.rb
Localisation updates from https://translatewiki.net.
[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, :hide, :unhide].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, DiaryComment), "should not be able to #{action} DiaryComment"
19     end
20
21     [:index, :show, :resolve, :ignore, :reopen].each do |action|
22       assert ability.cannot?(action, Issue), "should not be able to #{action} Issues"
23     end
24   end
25 end