about summary refs log tree commit diff
path: root/spec/policies/subscription_policy_spec.rb
diff options
context:
space:
mode:
authorpluralcafe-docker <git@plural.cafe>2018-12-27 21:35:47 +0000
committerpluralcafe-docker <git@plural.cafe>2018-12-27 21:35:47 +0000
commit797a8429a0deb511e6d6092edad39f856231534e (patch)
tree6e44d3c2a5a662dfc4e4087fdc391b8e7bb41dba /spec/policies/subscription_policy_spec.rb
parent94894b8a6ad1247306497dc8c0c47d52a8a2f72c (diff)
parentf349fe2159fb36e598263f2797f041417ef7c2da (diff)
Merge branch 'glitch'
Diffstat (limited to 'spec/policies/subscription_policy_spec.rb')
-rw-r--r--spec/policies/subscription_policy_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/policies/subscription_policy_spec.rb b/spec/policies/subscription_policy_spec.rb
new file mode 100644
index 000000000..21d60c15f
--- /dev/null
+++ b/spec/policies/subscription_policy_spec.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+require 'pundit/rspec'
+
+RSpec.describe SubscriptionPolicy do
+  let(:subject) { described_class }
+  let(:admin)   { Fabricate(:user, admin: true).account }
+  let(:john)    { Fabricate(:user).account }
+
+  permissions :index? do
+    context 'admin?' do
+      it 'permits' do
+        expect(subject).to permit(admin, Subscription)
+      end
+    end
+
+    context '!admin?' do
+      it 'denies' do
+        expect(subject).to_not permit(john, Subscription)
+      end
+    end
+  end
+end