about summary refs log tree commit diff
path: root/spec/policies/subscription_policy_spec.rb
diff options
context:
space:
mode:
authorysksn <bluewhale1982@gmail.com>2018-12-21 01:52:07 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-12-20 17:52:07 +0100
commitb93e3178863fee1d6cb1da1f6baa5bb038903af4 (patch)
tree4dd19dd57bd5dbcced25eb565fa5a4aff5e5191e /spec/policies/subscription_policy_spec.rb
parentbe9640bfc2be49961fef163510f630f481e02566 (diff)
Add specs for policies (#9591)
* Add spec for RelayPolicy

* Add specs for SubscriptionPolicy

* Add specs for SettingsPolicy

* Add specs for TagPolicy

* Add specs for ReportPolicy
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