mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 15:31:52 +00:00
Reduce factory creation (14 -> 8) in ActivityPub::Activity::Block
spec (#32488)
This commit is contained in:
parent
27f05e9016
commit
e9b27852be
|
@ -3,6 +3,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Block do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
let(:sender) { Fabricate(:account) }
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
|
||||
|
@ -16,61 +18,39 @@ RSpec.describe ActivityPub::Activity::Block do
|
|||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
context 'when the recipient does not follow the sender' do
|
||||
describe '#perform' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
context 'when the recipient does not follow the sender' do
|
||||
it 'creates a block from sender to recipient' do
|
||||
expect(sender.blocking?(recipient)).to be true
|
||||
end
|
||||
subject.perform
|
||||
|
||||
expect(sender)
|
||||
.to be_blocking(recipient)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the recipient is already blocked' do
|
||||
before do
|
||||
sender.block!(recipient, uri: 'old')
|
||||
end
|
||||
before { sender.block!(recipient, uri: 'old') }
|
||||
|
||||
describe '#perform' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
before do
|
||||
it 'creates a block from sender to recipient and sets uri to last received block activity' do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'creates a block from sender to recipient' do
|
||||
expect(sender.blocking?(recipient)).to be true
|
||||
end
|
||||
|
||||
it 'sets the uri to that of last received block activity' do
|
||||
expect(sender.block_relationships.find_by(target_account: recipient).uri).to eq 'foo'
|
||||
end
|
||||
expect(sender)
|
||||
.to be_blocking(recipient)
|
||||
expect(sender.block_relationships.find_by(target_account: recipient).uri)
|
||||
.to eq 'foo'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the recipient follows the sender' do
|
||||
before do
|
||||
recipient.follow!(sender)
|
||||
end
|
||||
before { recipient.follow!(sender) }
|
||||
|
||||
describe '#perform' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
before do
|
||||
it 'creates a block from sender to recipient and ensures recipient not following sender' do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'creates a block from sender to recipient' do
|
||||
expect(sender.blocking?(recipient)).to be true
|
||||
end
|
||||
|
||||
it 'ensures recipient is not following sender' do
|
||||
expect(recipient.following?(sender)).to be false
|
||||
end
|
||||
expect(sender)
|
||||
.to be_blocking(recipient)
|
||||
expect(recipient)
|
||||
.to_not be_following(sender)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -90,19 +70,13 @@ RSpec.describe ActivityPub::Activity::Block do
|
|||
ActivityPub::Activity::Undo.new(undo_json, sender).perform
|
||||
end
|
||||
|
||||
describe '#perform' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
before do
|
||||
it 'does not create a block from sender to recipient and ensures recipient not following sender' do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'does not create a block from sender to recipient' do
|
||||
expect(sender.blocking?(recipient)).to be false
|
||||
end
|
||||
|
||||
it 'ensures recipient is not following sender' do
|
||||
expect(recipient.following?(sender)).to be false
|
||||
expect(sender)
|
||||
.to_not be_blocking(recipient)
|
||||
expect(recipient)
|
||||
.to_not be_following(sender)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user