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