Remove nil ApiCapability user branch
This commit is contained in:
parent
ccc70fb914
commit
e7fb89c8d0
2 changed files with 1 additions and 7 deletions
|
@ -5,7 +5,7 @@ class ApiCapability
|
||||||
|
|
||||||
def initialize(token)
|
def initialize(token)
|
||||||
if Settings.status != "database_offline"
|
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?
|
if user&.active?
|
||||||
can [:create, :comment, :close, :reopen], Note if scope?(token, :write_notes)
|
can [:create, :comment, :close, :reopen], Note if scope?(token, :write_notes)
|
||||||
|
|
|
@ -88,12 +88,6 @@ end
|
||||||
|
|
||||||
class UserApiCapabilityTest < ActiveSupport::TestCase
|
class UserApiCapabilityTest < ActiveSupport::TestCase
|
||||||
test "user preferences" do
|
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
|
# A user with empty tokens
|
||||||
token = create(:oauth_access_token)
|
token = create(:oauth_access_token)
|
||||||
capability = ApiCapability.new token
|
capability = ApiCapability.new token
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue