diff options
author | Thibaut Girka <thib@sitedethib.com> | 2020-11-08 14:20:35 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2020-11-08 14:20:35 +0100 |
commit | 0437d70628bcd852c303432562c74202554fe9cb (patch) | |
tree | 27b6ff5abf280517ae6a8abd585f15e02d35fd58 /spec/policies | |
parent | cfb16b9b70a50ec5451c9aebb2c35d3a44701311 (diff) | |
parent | 3134691948aeacb16b7386ed77bbea4581beec40 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - `app/controllers/follower_accounts_controller.rb`: Conflict due to upstream changing suspension logic while glitch-soc has an extra option to hide followers count. Ported upstream changes.
Diffstat (limited to 'spec/policies')
-rw-r--r-- | spec/policies/account_policy_spec.rb | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/spec/policies/account_policy_spec.rb b/spec/policies/account_policy_spec.rb index d27e9d5b0..1347ca4a0 100644 --- a/spec/policies/account_policy_spec.rb +++ b/spec/policies/account_policy_spec.rb @@ -7,8 +7,9 @@ RSpec.describe AccountPolicy do let(:subject) { described_class } let(:admin) { Fabricate(:user, admin: true).account } let(:john) { Fabricate(:user).account } + let(:alice) { Fabricate(:user).account } - permissions :index?, :show?, :unsuspend?, :unsensitive?, :unsilence?, :remove_avatar?, :remove_header? do + permissions :index? do context 'staff' do it 'permits' do expect(subject).to permit(admin) @@ -22,6 +23,38 @@ RSpec.describe AccountPolicy do end end + permissions :show?, :unsilence?, :unsensitive?, :remove_avatar?, :remove_header? do + context 'staff' do + it 'permits' do + expect(subject).to permit(admin, alice) + end + end + + context 'not staff' do + it 'denies' do + expect(subject).to_not permit(john, alice) + end + end + end + + permissions :unsuspend? do + before do + alice.suspend! + end + + context 'staff' do + it 'permits' do + expect(subject).to permit(admin, alice) + end + end + + context 'not staff' do + it 'denies' do + expect(subject).to_not permit(john, alice) + end + end + end + permissions :redownload?, :subscribe?, :unsubscribe? do context 'admin' do it 'permits' do |