mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 22:15:23 +01:00
Fix RSpec/RepeatedExample cop (#24849)
This commit is contained in:
parent
9f5deb310b
commit
e387175fc9
2 changed files with 93 additions and 85 deletions
|
@ -571,10 +571,6 @@ RSpec/PredicateMatcher:
|
|||
- 'spec/models/user_spec.rb'
|
||||
- 'spec/services/post_status_service_spec.rb'
|
||||
|
||||
RSpec/RepeatedExample:
|
||||
Exclude:
|
||||
- 'spec/policies/status_policy_spec.rb'
|
||||
|
||||
RSpec/StubbedMock:
|
||||
Exclude:
|
||||
- 'spec/controllers/api/base_controller_spec.rb'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue