Commit c6dbd435 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Rename the module and add a simple test to check

if all methods are also presented in the user.
parent 02732e85
class DeployToken < ActiveRecord::Base class DeployToken < ActiveRecord::Base
include Expirable include Expirable
include TokenAuthenticatable include TokenAuthenticatable
include PolicyCheckable include PolicyActor
add_authentication_token_field :token add_authentication_token_field :token
AVAILABLE_SCOPES = %i(read_repository read_registry).freeze AVAILABLE_SCOPES = %i(read_repository read_registry).freeze
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
# Include this module if we want to pass something else than the user to # Include this module if we want to pass something else than the user to
# check policies. This defines several methods which the policy checker # check policies. This defines several methods which the policy checker
# would call and check. # would call and check.
module PolicyCheckable module PolicyActor
extend ActiveSupport::Concern extend ActiveSupport::Concern
prepend EE::PolicyCheckable prepend EE::PolicyActor
def blocked? def blocked?
false false
......
# frozen_string_literal: true # frozen_string_literal: true
module EE module EE
module PolicyCheckable module PolicyActor
def auditor? def auditor?
false false
end end
......
# frozen_string_literal: true
require 'spec_helper'
describe PolicyActor do
it 'implements all the methods from user' do
methods = subject.instance_methods
# User.instance_methods do not return all methods until an instance is
# initialized. So here we just use an instance
expect(build(:user).methods).to include(*methods)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment