Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Mar 26, 2024
1 parent b0a3852 commit 82a3163
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
let(:alice) { Fabricate(:account, username: 'alice') }

before do
NotificationPermission.create!(account: alice, from_account: wolf)

wolf.follow!(alice)
alice.follow!(dog)
end

it 'purges followers from blocked domain, sends them Reject->Follow, and records severed relationships', :aggregate_failures do
it 'purge followers from blocked domain, remove notification permissions, sends `Reject->Follow`, and records severed relationships', :aggregate_failures do
expect { subject.call(alice, 'evil.org') }
.to change { wolf.following?(alice) }.from(true).to(false)
.and change { NotificationPermission.exists?(account: alice, from_account: wolf) }.from(true).to(false)

expect(ActivityPub::DeliveryWorker.jobs.pluck('args')).to contain_exactly(
[a_string_including('"type":"Reject"'), alice.id, wolf.inbox_url],
Expand Down
7 changes: 6 additions & 1 deletion spec/services/block_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
describe 'local' do
let(:bob) { Fabricate(:account, username: 'bob') }

it 'creates a blocking relation' do
before do
NotificationPermission.create!(account: sender, from_account: bob)
end

it 'creates a blocking relation and removes notification permissions' do
expect { subject.call(sender, bob) }
.to change { sender.blocking?(bob) }.from(false).to(true)
.and change { NotificationPermission.exists?(account: sender, from_account: bob) }.from(true).to(false)
end
end

Expand Down

0 comments on commit 82a3163

Please sign in to comment.