X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/0c79686f3cef86330d0ab6bbef2a9e2275ac93ac..f4369334333a5444492c616ac32cc3b842f6a7ad:/test/abilities/api_capability_test.rb?ds=sidebyside diff --git a/test/abilities/api_capability_test.rb b/test/abilities/api_capability_test.rb index 8d0e682f6..dccde5758 100644 --- a/test/abilities/api_capability_test.rb +++ b/test/abilities/api_capability_test.rb @@ -3,6 +3,8 @@ require "test_helper" class ApiCapabilityTest < ActiveSupport::TestCase + private + def tokens(*toks) AccessToken.new do |token| toks.each do |t| @@ -100,33 +102,33 @@ class UserApiCapabilityTest < ApiCapabilityTest test "user preferences" do # a user with no tokens capability = ApiCapability.new nil - [:read, :read_one, :update, :update_one, :delete_one].each do |act| + [:index, :show, :update_all, :update, :destroy].each do |act| assert capability.cannot? act, UserPreference end # A user with empty tokens capability = ApiCapability.new tokens - [:read, :read_one, :update, :update_one, :delete_one].each do |act| + [:index, :show, :update_all, :update, :destroy].each do |act| assert capability.cannot? act, UserPreference end capability = ApiCapability.new tokens(:allow_read_prefs) - [:update, :update_one, :delete_one].each do |act| + [:update_all, :update, :destroy].each do |act| assert capability.cannot? act, UserPreference end - [:read, :read_one].each do |act| + [:index, :show].each do |act| assert capability.can? act, UserPreference end capability = ApiCapability.new tokens(:allow_write_prefs) - [:read, :read_one].each do |act| + [:index, :show].each do |act| assert capability.cannot? act, UserPreference end - [:update, :update_one, :delete_one].each do |act| + [:update_all, :update, :destroy].each do |act| assert capability.can? act, UserPreference end end