|
|
|
@ -11,6 +11,7 @@ RSpec.describe StatusPolicy, type: :model do
|
|
|
|
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
|
|
|
|
let(:status) { Fabricate(:status, account: alice) }
|
|
|
|
|
|
|
|
|
|
context 'with the permissions of show? and reblog?' do
|
|
|
|
|
permissions :show?, :reblog? do
|
|
|
|
|
it 'grants access when no viewer' do
|
|
|
|
|
expect(subject).to permit(nil, status)
|
|
|
|
@ -24,7 +25,9 @@ RSpec.describe StatusPolicy, type: :model do
|
|
|
|
|
expect(subject).to_not permit(block.account, status)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with the permission of show?' do
|
|
|
|
|
permissions :show? do
|
|
|
|
|
it 'grants access when direct and account is viewer' do
|
|
|
|
|
status.visibility = :direct
|
|
|
|
@ -82,7 +85,9 @@ RSpec.describe StatusPolicy, type: :model do
|
|
|
|
|
expect(subject).to_not permit(viewer, status)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with the permission of reblog?' do
|
|
|
|
|
permissions :reblog? do
|
|
|
|
|
it 'denies access when private' do
|
|
|
|
|
viewer = Fabricate(:account)
|
|
|
|
@ -98,7 +103,9 @@ RSpec.describe StatusPolicy, type: :model do
|
|
|
|
|
expect(subject).to_not permit(viewer, status)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with the permissions of destroy? and unreblog?' do
|
|
|
|
|
permissions :destroy?, :unreblog? do
|
|
|
|
|
it 'grants access when account is deleter' do
|
|
|
|
|
expect(subject).to permit(status.account, status)
|
|
|
|
@ -112,7 +119,9 @@ RSpec.describe StatusPolicy, type: :model do
|
|
|
|
|
expect(subject).to_not permit(nil, status)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with the permission of favourite?' do
|
|
|
|
|
permissions :favourite? do
|
|
|
|
|
it 'grants access when viewer is not blocked' do
|
|
|
|
|
follow = Fabricate(:follow)
|
|
|
|
@ -128,10 +137,13 @@ RSpec.describe StatusPolicy, type: :model do
|
|
|
|
|
expect(subject).to_not permit(block.account, status)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with the permission of update?' do
|
|
|
|
|
permissions :update? do
|
|
|
|
|
it 'grants access if owner' do
|
|
|
|
|
expect(subject).to permit(status.account, status)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|