about summary refs log tree commit diff
path: root/spec/policies
diff options
context:
space:
mode:
authorJack Jennings <jack@standard-library.com>2017-05-30 13:56:31 -0700
committerEugen Rochko <eugen@zeonfederated.com>2017-05-30 22:56:31 +0200
commit33f669a5f851b4095fb6189147ae0fe6f8343d44 (patch)
treed62452304cfc4a2a1414ca7f00e0947b4ab34359 /spec/policies
parent3576fa0d591db69a1727153a1130ff5bebf37167 (diff)
Add status destroy authorization to policy (#3453)
* Add status destroy authorization to policy

* Create explicit unreblog status authorization
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/status_policy_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/policies/status_policy_spec.rb b/spec/policies/status_policy_spec.rb
index 8e85efb8e..bacb8fd9e 100644
--- a/spec/policies/status_policy_spec.rb
+++ b/spec/policies/status_policy_spec.rb
@@ -4,7 +4,9 @@ require 'pundit/rspec'
 RSpec.describe StatusPolicy, type: :model do
   subject { described_class }
 
+  let(:admin) { Fabricate(:user, admin: true) }
   let(:alice) { Fabricate(:account, username: 'alice') }
+  let(:bob) { Fabricate(:account, username: 'bob') }
   let(:status) { Fabricate(:status, account: alice) }
 
   permissions :show?, :reblog? do
@@ -86,4 +88,22 @@ RSpec.describe StatusPolicy, type: :model do
       expect(subject).to_not permit(viewer, status)
     end
   end
+
+  permissions :destroy?, :unreblog? do
+    it 'grants access when account is deleter' do
+      expect(subject).to permit(status.account, status)
+    end
+
+    it 'grants access when account is admin' do
+      expect(subject).to permit(admin.account, status)
+    end
+
+    it 'denies access when account is not deleter' do
+      expect(subject).to_not permit(bob, status)
+    end
+
+    it 'denies access when no deleter' do
+      expect(subject).to_not permit(nil, status)
+    end
+  end
 end