# All users can grant permissions on objects they own
head_obj = self.class.
- kind_class(self.head_uuid).
+ resource_class_for_uuid(self.head_uuid).
where('uuid=?',head_uuid).
first
if head_obj
end
class ActiveSupport::TestCase
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
- #
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
- # -- they do not yet inherit this setting
fixtures :all
include ArvadosTestSupport
Thread.current[:user] = nil
end
+ def set_user_from_auth(auth_name)
+ client_auth = api_client_authorizations(auth_name)
+ Thread.current[:api_client_authorization] = client_auth
+ Thread.current[:api_client] = client_auth.api_client
+ Thread.current[:user] = client_auth.user
+ end
+
def expect_json
self.request.headers["Accept"] = "text/json"
end
end
end
- def set_user_from_auth(auth_name)
- client_auth = api_client_authorizations(auth_name)
- Thread.current[:api_client_authorization] = client_auth
- Thread.current[:api_client] = client_auth.api_client
- Thread.current[:user] = client_auth.user
- end
-
test "creating a user makes a log" do
set_user_from_auth :admin_trustedclient
u = User.new(first_name: "Log", last_name: "Test")
--- /dev/null
+require 'test_helper'
+
+class PermissionTest < ActiveSupport::TestCase
+ test "Grant permissions on an object I own" do
+ set_user_from_auth :active_trustedclient
+
+ ob = Specimen.create
+ assert ob.save
+
+ # Ensure I have permission to manage this group even when its owner changes
+ perm_link = Link.create(tail_uuid: users(:active).uuid,
+ head_uuid: ob.uuid,
+ link_class: 'permission',
+ name: 'can_manage')
+ assert perm_link.save, "should give myself permission on my own object"
+ end
+end