Fix RSpec/RepeatedExample cop (#24849)
parent
9f5deb310b
commit
e387175fc9
|
@ -571,10 +571,6 @@ RSpec/PredicateMatcher:
|
||||||
- 'spec/models/user_spec.rb'
|
- 'spec/models/user_spec.rb'
|
||||||
- 'spec/services/post_status_service_spec.rb'
|
- 'spec/services/post_status_service_spec.rb'
|
||||||
|
|
||||||
RSpec/RepeatedExample:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/policies/status_policy_spec.rb'
|
|
||||||
|
|
||||||
RSpec/StubbedMock:
|
RSpec/StubbedMock:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'spec/controllers/api/base_controller_spec.rb'
|
- 'spec/controllers/api/base_controller_spec.rb'
|
||||||
|
|
|
@ -11,6 +11,7 @@ RSpec.describe StatusPolicy, type: :model do
|
||||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
let(:status) { Fabricate(:status, account: alice) }
|
let(:status) { Fabricate(:status, account: alice) }
|
||||||
|
|
||||||
|
context 'with the permissions of show? and reblog?' do
|
||||||
permissions :show?, :reblog? do
|
permissions :show?, :reblog? do
|
||||||
it 'grants access when no viewer' do
|
it 'grants access when no viewer' do
|
||||||
expect(subject).to permit(nil, status)
|
expect(subject).to permit(nil, status)
|
||||||
|
@ -24,7 +25,9 @@ RSpec.describe StatusPolicy, type: :model do
|
||||||
expect(subject).to_not permit(block.account, status)
|
expect(subject).to_not permit(block.account, status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with the permission of show?' do
|
||||||
permissions :show? do
|
permissions :show? do
|
||||||
it 'grants access when direct and account is viewer' do
|
it 'grants access when direct and account is viewer' do
|
||||||
status.visibility = :direct
|
status.visibility = :direct
|
||||||
|
@ -82,7 +85,9 @@ RSpec.describe StatusPolicy, type: :model do
|
||||||
expect(subject).to_not permit(viewer, status)
|
expect(subject).to_not permit(viewer, status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with the permission of reblog?' do
|
||||||
permissions :reblog? do
|
permissions :reblog? do
|
||||||
it 'denies access when private' do
|
it 'denies access when private' do
|
||||||
viewer = Fabricate(:account)
|
viewer = Fabricate(:account)
|
||||||
|
@ -98,7 +103,9 @@ RSpec.describe StatusPolicy, type: :model do
|
||||||
expect(subject).to_not permit(viewer, status)
|
expect(subject).to_not permit(viewer, status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with the permissions of destroy? and unreblog?' do
|
||||||
permissions :destroy?, :unreblog? do
|
permissions :destroy?, :unreblog? do
|
||||||
it 'grants access when account is deleter' do
|
it 'grants access when account is deleter' do
|
||||||
expect(subject).to permit(status.account, status)
|
expect(subject).to permit(status.account, status)
|
||||||
|
@ -112,7 +119,9 @@ RSpec.describe StatusPolicy, type: :model do
|
||||||
expect(subject).to_not permit(nil, status)
|
expect(subject).to_not permit(nil, status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with the permission of favourite?' do
|
||||||
permissions :favourite? do
|
permissions :favourite? do
|
||||||
it 'grants access when viewer is not blocked' do
|
it 'grants access when viewer is not blocked' do
|
||||||
follow = Fabricate(:follow)
|
follow = Fabricate(:follow)
|
||||||
|
@ -128,10 +137,13 @@ RSpec.describe StatusPolicy, type: :model do
|
||||||
expect(subject).to_not permit(block.account, status)
|
expect(subject).to_not permit(block.account, status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with the permission of update?' do
|
||||||
permissions :update? do
|
permissions :update? do
|
||||||
it 'grants access if owner' do
|
it 'grants access if owner' do
|
||||||
expect(subject).to permit(status.account, status)
|
expect(subject).to permit(status.account, status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue