Rename the module and add a simple test to check
if all methods are also presented in the user.
This commit is contained in:
parent
e3aaa56c92
commit
b577faf785
3 changed files with 15 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
|||
class DeployToken < ActiveRecord::Base
|
||||
include Expirable
|
||||
include TokenAuthenticatable
|
||||
include PolicyCheckable
|
||||
include PolicyActor
|
||||
add_authentication_token_field :token
|
||||
|
||||
AVAILABLE_SCOPES = %i(read_repository read_registry).freeze
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Include this module if we want to pass something else than the user to
|
||||
# check policies. This defines several methods which the policy checker
|
||||
# would call and check.
|
||||
module PolicyCheckable
|
||||
module PolicyActor
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def blocked?
|
13
spec/policies/concerns/policy_actor_spec.rb
Normal file
13
spec/policies/concerns/policy_actor_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# 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
|
Loading…
Reference in a new issue