summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-07-27 17:37:19 +0800
committerLin Jen-Shin <godfat@godfat.org>2018-07-27 17:52:45 +0800
commitb577faf785a2c04f8376e3dc597dc0d6ec0b753d (patch)
tree3968919ef5dff80b90825182c9701486005b9407
parente3aaa56c92f97f8aff3aeb847754794e9eae4706 (diff)
downloadgitlab-ce-b577faf785a2c04f8376e3dc597dc0d6ec0b753d.tar.gz
Rename the module and add a simple test to check
if all methods are also presented in the user.
-rw-r--r--app/models/deploy_token.rb2
-rw-r--r--app/policies/concerns/policy_actor.rb (renamed from app/policies/concerns/policy_checkable.rb)2
-rw-r--r--spec/policies/concerns/policy_actor_spec.rb13
3 files changed, 15 insertions, 2 deletions
diff --git a/app/models/deploy_token.rb b/app/models/deploy_token.rb
index 51029950dda..fdbe95059e5 100644
--- a/app/models/deploy_token.rb
+++ b/app/models/deploy_token.rb
@@ -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
diff --git a/app/policies/concerns/policy_checkable.rb b/app/policies/concerns/policy_actor.rb
index 5aae23c18e9..069d065280e 100644
--- a/app/policies/concerns/policy_checkable.rb
+++ b/app/policies/concerns/policy_actor.rb
@@ -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?
diff --git a/spec/policies/concerns/policy_actor_spec.rb b/spec/policies/concerns/policy_actor_spec.rb
new file mode 100644
index 00000000000..27db9710a38
--- /dev/null
+++ b/spec/policies/concerns/policy_actor_spec.rb
@@ -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