summaryrefslogtreecommitdiff
path: root/spec/policies
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-01-09 21:43:15 +0100
committerRémy Coutable <remy@rymai.me>2017-01-18 16:38:34 +0100
commitfd72c0f4c748658f539d24a286366e9ac7a22b57 (patch)
tree008efd12ec9d7a4798a338add49b777ffe5f6676 /spec/policies
parentb4f67cc2294f262d35fe63cc1e60eccebc4667ac (diff)
downloadgitlab-ce-fd72c0f4c748658f539d24a286366e9ac7a22b57.tar.gz
Handle presenters in BasePolicy
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/base_policy_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/policies/base_policy_spec.rb b/spec/policies/base_policy_spec.rb
new file mode 100644
index 00000000000..439d6436f34
--- /dev/null
+++ b/spec/policies/base_policy_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe BasePolicy, models: true do
+ let(:build) { create(:ci_build) }
+
+ describe '.class_for' do
+ it 'detects policy class based on the subject ancestors' do
+ expect(described_class.class_for(build)).to eq(Ci::BuildPolicy)
+ end
+
+ it 'detects policy class for a presented subject' do
+ presentee = Ci::Build::Presenter.new(build)
+
+ expect(described_class.class_for(presentee)).to eq(Ci::BuildPolicy)
+ end
+ end
+end