def initialize(token)
if Settings.status != "database_offline"
- user = (User.find(token.resource_owner_id) if token.respond_to?(:resource_owner_id))
+ user = User.find(token.resource_owner_id)
if user&.active?
can [:create, :comment, :close, :reopen], Note if scope?(token, :write_notes)
class UserApiCapabilityTest < ActiveSupport::TestCase
test "user preferences" do
- # a user with no tokens
- capability = ApiCapability.new nil
- [:index, :show, :update_all, :update, :destroy].each do |act|
- assert capability.cannot? act, UserPreference
- end
-
# A user with empty tokens
token = create(:oauth_access_token)
capability = ApiCapability.new token