mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-29 15:13:11 +01:00
Merge commit '00cb4a0313190bfa118966692a649db9c8328094' into glitch-soc/merge-upstream
This commit is contained in:
@@ -4,5 +4,4 @@ Fabricator(:notification_request) do
|
||||
account
|
||||
from_account { Fabricate.build(:account) }
|
||||
last_status { Fabricate.build(:status) }
|
||||
dismissed false
|
||||
end
|
||||
|
||||
@@ -17,32 +17,21 @@ RSpec.describe Vacuum::MediaAttachmentsVacuum do
|
||||
let!(:old_unattached_media) { Fabricate(:media_attachment, account_id: nil, created_at: 10.days.ago) }
|
||||
let!(:new_unattached_media) { Fabricate(:media_attachment, account_id: nil, created_at: 1.hour.ago) }
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
before { subject.perform }
|
||||
|
||||
it 'deletes cache of remote media attachments past the retention period' do
|
||||
expect(old_remote_media.reload.file).to be_blank
|
||||
end
|
||||
|
||||
it 'does not touch local media attachments past the retention period' do
|
||||
expect(old_local_media.reload.file).to_not be_blank
|
||||
end
|
||||
|
||||
it 'does not delete cache of remote media attachments within the retention period' do
|
||||
expect(new_remote_media.reload.file).to_not be_blank
|
||||
end
|
||||
|
||||
it 'does not touch local media attachments within the retention period' do
|
||||
expect(new_local_media.reload.file).to_not be_blank
|
||||
end
|
||||
|
||||
it 'deletes unattached media attachments past TTL' do
|
||||
expect { old_unattached_media.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'does not delete unattached media attachments within TTL' do
|
||||
expect(new_unattached_media.reload).to be_persisted
|
||||
it 'handles attachments based on metadata details' do
|
||||
expect(old_remote_media.reload.file) # Remote and past retention period
|
||||
.to be_blank
|
||||
expect(old_local_media.reload.file) # Local and past retention
|
||||
.to_not be_blank
|
||||
expect(new_remote_media.reload.file) # Remote and within retention
|
||||
.to_not be_blank
|
||||
expect(new_local_media.reload.file) # Local and within retention
|
||||
.to_not be_blank
|
||||
expect { old_unattached_media.reload } # Unattached and past TTL
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(new_unattached_media.reload) # Unattached and within TTL
|
||||
.to be_persisted
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,9 +4,7 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe NotificationRequest do
|
||||
describe '#reconsider_existence!' do
|
||||
subject { Fabricate(:notification_request, dismissed: dismissed) }
|
||||
|
||||
let(:dismissed) { false }
|
||||
subject { Fabricate(:notification_request) }
|
||||
|
||||
context 'when there are remaining notifications' do
|
||||
before do
|
||||
@@ -28,14 +26,6 @@ RSpec.describe NotificationRequest do
|
||||
subject.reconsider_existence!
|
||||
end
|
||||
|
||||
context 'when dismissed' do
|
||||
let(:dismissed) { true }
|
||||
|
||||
it 'leaves request intact' do
|
||||
expect(subject.destroyed?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
it 'removes the request' do
|
||||
expect(subject.destroyed?).to be true
|
||||
end
|
||||
|
||||
@@ -17,7 +17,6 @@ RSpec.describe 'Requests' do
|
||||
|
||||
before do
|
||||
Fabricate(:notification_request, account: user.account)
|
||||
Fabricate(:notification_request, account: user.account, dismissed: true)
|
||||
end
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write write:notifications'
|
||||
@@ -29,16 +28,6 @@ RSpec.describe 'Requests' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with dismissed' do
|
||||
let(:params) { { dismissed: '1' } }
|
||||
|
||||
it 'returns http success', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /api/v1/notifications/requests/:id/accept' do
|
||||
@@ -78,15 +67,14 @@ RSpec.describe 'Requests' do
|
||||
post "/api/v1/notifications/requests/#{notification_request.id}/dismiss", headers: headers
|
||||
end
|
||||
|
||||
let(:notification_request) { Fabricate(:notification_request, account: user.account) }
|
||||
let!(:notification_request) { Fabricate(:notification_request, account: user.account) }
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'read read:notifications'
|
||||
|
||||
it 'returns http success and dismisses the notification request', :aggregate_failures do
|
||||
subject
|
||||
it 'returns http success and destroys the notification request', :aggregate_failures do
|
||||
expect { subject }.to change(NotificationRequest, :count).by(-1)
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(notification_request.reload.dismissed?).to be true
|
||||
end
|
||||
|
||||
context 'when notification request belongs to someone else' do
|
||||
|
||||
@@ -129,6 +129,39 @@ RSpec.describe NotifyService do
|
||||
end
|
||||
end
|
||||
|
||||
context 'with filtered notifications' do
|
||||
let(:unknown) { Fabricate(:account, username: 'unknown') }
|
||||
let(:status) { Fabricate(:status, account: unknown) }
|
||||
let(:activity) { Fabricate(:mention, account: recipient, status: status) }
|
||||
let(:type) { :mention }
|
||||
|
||||
before do
|
||||
Fabricate(:notification_policy, account: recipient, filter_not_following: true)
|
||||
end
|
||||
|
||||
it 'creates a filtered notification' do
|
||||
expect { subject }.to change(Notification, :count)
|
||||
expect(Notification.last).to be_filtered
|
||||
end
|
||||
|
||||
context 'when no notification request exists' do
|
||||
it 'creates a notification request' do
|
||||
expect { subject }.to change(NotificationRequest, :count)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a notification request exists' do
|
||||
let!(:notification_request) do
|
||||
Fabricate(:notification_request, account: recipient, from_account: unknown, last_status: Fabricate(:status, account: unknown))
|
||||
end
|
||||
|
||||
it 'updates the existing notification request' do
|
||||
expect { subject }.to_not change(NotificationRequest, :count)
|
||||
expect(notification_request.reload.last_status).to eq status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe NotifyService::DismissCondition do
|
||||
subject { described_class.new(notification) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user