X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/25256a484914ee40d829d9184fb4107dd0a77d44..7a177cb03f0b8865cbf8cdea95208046450776ff:/test/models/abilities_test.rb?ds=inline diff --git a/test/models/abilities_test.rb b/test/models/abilities_test.rb index 28a5c7fd9..fc37b0e7d 100644 --- a/test/models/abilities_test.rb +++ b/test/models/abilities_test.rb @@ -17,13 +17,13 @@ class GuestAbilityTest < AbilityTest test "diary permissions for a guest" do ability = Ability.new nil - [:list, :rss, :view, :comments].each do |action| + [:index, :rss, :show, :comments].each do |action| assert ability.can?(action, DiaryEntry), "should be able to #{action} DiaryEntries" end [:create, :edit, :comment, :subscribe, :unsubscribe, :hide, :hidecomment].each do |action| - assert ability.cannot?(action, DiaryEntry), "should be able to #{action} DiaryEntries" - assert ability.cannot?(action, DiaryComment), "should be able to #{action} DiaryEntries" + assert ability.cannot?(action, DiaryEntry), "should not be able to #{action} DiaryEntries" + assert ability.cannot?(action, DiaryComment), "should not be able to #{action} DiaryEntries" end end end @@ -32,13 +32,27 @@ class UserAbilityTest < AbilityTest test "Diary permissions" do ability = Ability.new create(:user) - [:list, :rss, :view, :comments, :create, :edit, :comment, :subscribe, :unsubscribe].each do |action| + [:index, :rss, :show, :comments, :create, :edit, :comment, :subscribe, :unsubscribe].each do |action| assert ability.can?(action, DiaryEntry), "should be able to #{action} DiaryEntries" end [:hide, :hidecomment].each do |action| - assert ability.cannot?(action, DiaryEntry), "should be able to #{action} DiaryEntries" - assert ability.cannot?(action, DiaryComment), "should be able to #{action} DiaryEntries" + assert ability.cannot?(action, DiaryEntry), "should not be able to #{action} DiaryEntries" + assert ability.cannot?(action, DiaryComment), "should not be able to #{action} DiaryEntries" + end + + [:index, :show, :resolve, :ignore, :reopen].each do |action| + assert ability.cannot?(action, Issue), "should not be able to #{action} Issues" + end + end +end + +class ModeratorAbilityTest < AbilityTest + test "Issue permissions" do + ability = Ability.new create(:moderator_user) + + [:index, :show, :resolve, :ignore, :reopen].each do |action| + assert ability.can?(action, Issue), "should be able to #{action} Issues" end end end @@ -46,7 +60,7 @@ end class AdministratorAbilityTest < AbilityTest test "Diary for an administrator" do ability = Ability.new create(:administrator_user) - [:list, :rss, :view, :comments, :create, :edit, :comment, :subscribe, :unsubscribe, :hide, :hidecomment].each do |action| + [:index, :rss, :show, :comments, :create, :edit, :comment, :subscribe, :unsubscribe, :hide, :hidecomment].each do |action| assert ability.can?(action, DiaryEntry), "should be able to #{action} DiaryEntries" end @@ -54,12 +68,4 @@ class AdministratorAbilityTest < AbilityTest assert ability.can?(action, DiaryComment), "should be able to #{action} DiaryComment" end end - - test "administrator does not auto-grant user preferences" do - ability = Ability.new create(:administrator_user) - - [:read, :read_one, :update, :update_one, :delete_one].each do |act| - assert ability.cannot? act, UserPreference - end - end end