Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Mar 13, 2024
1 parent b868dd1 commit 53a1d72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -9,12 +9,15 @@
let!(:alice) { Fabricate(:account, username: 'alice') }

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

wolf.follow!(alice)
end

it 'purge followers from blocked domain and sends `Reject->Follow` accordingly' do
it 'purge followers from blocked domain, remove notification permissions, and sends `Reject->Follow` accordingly' 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).to have_enqueued_sidekiq_job(/Reject/, alice.id, wolf.inbox_url)
end
Expand Down
7 changes: 6 additions & 1 deletion spec/services/block_service_spec.rb
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 53a1d72

Please sign in to comment.