Merge commit '670e4655d13975e0597bd1c74ebeeeeffc4edc37' into glitch-soc/merge-upstream

This commit is contained in:
Claire committed 2024-08-07 19:22:25 +02:00
commit 06e034db15
123 files changed
+253 -135

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ RSpec.describe NotificationPolicy do
let(:sender) { Fabricate(:account) }
before do
Fabricate.times(2, :notification, account: subject.account, activity: Fabricate(:status, account: sender), filtered: true)
Fabricate.times(2, :notification, account: subject.account, activity: Fabricate(:status, account: sender), filtered: true, type: :mention)
Fabricate(:notification_request, account: subject.account, from_account: sender)
subject.summarize!
end
+1 -1
View File
@@ -8,7 +8,7 @@ RSpec.describe NotificationRequest do
context 'when there are remaining notifications' do
before do
Fabricate(:notification, account: subject.account, activity: Fabricate(:status, account: subject.from_account), filtered: true)
Fabricate(:notification, account: subject.account, activity: Fabricate(:status, account: subject.from_account), filtered: true, type: :mention)
subject.reconsider_existence!
end
@@ -0,0 +1,19 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe DismissNotificationRequestService do
describe '#call' do
let(:sender) { Fabricate(:account) }
let(:receiver) { Fabricate(:account) }
let(:request) { Fabricate(:notification_request, account: receiver, from_account: sender) }
it 'destroys the request and queues a worker', :aggregate_failures do
expect { described_class.new.call(request) }
.to change(request, :destroyed?).to(true)
expect(FilteredNotificationCleanupWorker)
.to have_enqueued_sidekiq_job(receiver.id, sender.id)
end
end
end
+34
View File
@@ -129,6 +129,40 @@ RSpec.describe NotifyService do
end
end
context 'when the blocked sender has a role' do
let(:sender) { Fabricate(:user, role: sender_role).account }
let(:activity) { Fabricate(:mention, status: Fabricate(:status, account: sender)) }
let(:type) { :mention }
before do
recipient.block!(sender)
end
context 'when the role is a visible moderator' do
let(:sender_role) { Fabricate(:user_role, highlighted: true, permissions: UserRole::FLAGS[:manage_users]) }
it 'does notify' do
expect { subject }.to change(Notification, :count)
end
end
context 'when the role is a non-visible moderator' do
let(:sender_role) { Fabricate(:user_role, highlighted: false, permissions: UserRole::FLAGS[:manage_users]) }
it 'does not notify' do
expect { subject }.to_not change(Notification, :count)
end
end
context 'when the role is a visible non-moderator' do
let(:sender_role) { Fabricate(:user_role, highlighted: true) }
it 'does not notify' do
expect { subject }.to_not change(Notification, :count)
end
end
end
context 'with filtered notifications' do
let(:unknown) { Fabricate(:account, username: 'unknown') }
let(:status) { Fabricate(:status, account: unknown) }
@@ -0,0 +1,24 @@
# frozen_string_literal: true
require 'rails_helper'
describe FilteredNotificationCleanupWorker do
describe '#perform' do
let(:sender) { Fabricate(:account) }
let(:recipient) { Fabricate(:account) }
let(:bystander) { Fabricate(:account) }
before do
Fabricate(:notification, account: recipient, activity: Fabricate(:favourite, account: sender), filtered: true)
Fabricate(:notification, account: recipient, activity: Fabricate(:favourite, account: bystander), filtered: true)
Fabricate(:notification, account: recipient, activity: Fabricate(:follow, account: sender), filtered: true)
Fabricate(:notification, account: recipient, activity: Fabricate(:favourite, account: bystander), filtered: true)
end
it 'deletes all filtered notifications to the account' do
expect { described_class.new.perform(recipient.id, sender.id) }
.to change { recipient.notifications.where(from_account: sender).count }.from(2).to(0)
.and(not_change { recipient.notifications.where(from_account: bystander).count })
end
end
end