Merge commit 'faed9bf9f1
' into kb-draft-15.8-lts
This commit is contained in:
commit
be6dc25206
23 changed files with 313 additions and 107 deletions
|
@ -42,8 +42,8 @@ RSpec.describe DeliveryFailureTracker do
|
|||
Fabricate(:unavailable_domain, domain: 'foo.bar')
|
||||
end
|
||||
|
||||
it 'removes URLs that are unavailable' do
|
||||
results = described_class.without_unavailable(['http://example.com/good/inbox', 'http://foo.bar/unavailable/inbox'])
|
||||
it 'removes URLs that are bogus or unavailable' do
|
||||
results = described_class.without_unavailable(['http://example.com/good/inbox', 'http://foo.bar/unavailable/inbox', '{foo:'])
|
||||
|
||||
expect(results).to include('http://example.com/good/inbox')
|
||||
expect(results).to_not include('http://foo.bar/unavailable/inbox')
|
||||
|
|
|
@ -143,6 +143,55 @@ RSpec.describe 'Notifications' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when there are numerous notifications for the same final group' do
|
||||
before do
|
||||
user.account.notifications.destroy_all
|
||||
5.times.each { FavouriteService.new.call(Fabricate(:account), user.account.statuses.first) }
|
||||
end
|
||||
|
||||
context 'with no options' do
|
||||
it 'returns a notification group covering all notifications' do
|
||||
subject
|
||||
|
||||
notification_ids = user.account.notifications.reload.pluck(:id)
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:notification_groups]).to contain_exactly(
|
||||
a_hash_including(
|
||||
type: 'favourite',
|
||||
sample_account_ids: have_attributes(size: 5),
|
||||
page_min_id: notification_ids.first.to_s,
|
||||
page_max_id: notification_ids.last.to_s
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with min_id param' do
|
||||
let(:params) { { min_id: user.account.notifications.reload.first.id - 1 } }
|
||||
|
||||
it 'returns a notification group covering all notifications' do
|
||||
subject
|
||||
|
||||
notification_ids = user.account.notifications.reload.pluck(:id)
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:notification_groups]).to contain_exactly(
|
||||
a_hash_including(
|
||||
type: 'favourite',
|
||||
sample_account_ids: have_attributes(size: 5),
|
||||
page_min_id: notification_ids.first.to_s,
|
||||
page_max_id: notification_ids.last.to_s
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with no options' do
|
||||
it 'returns expected notification types', :aggregate_failures do
|
||||
subject
|
||||
|
|
58
spec/serializers/rest/preview_card_serializer_spec.rb
Normal file
58
spec/serializers/rest/preview_card_serializer_spec.rb
Normal file
|
@ -0,0 +1,58 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe REST::PreviewCardSerializer do
|
||||
subject do
|
||||
serialized_record_json(
|
||||
preview_card,
|
||||
described_class
|
||||
)
|
||||
end
|
||||
|
||||
context 'when preview card does not have author data' do
|
||||
let(:preview_card) { Fabricate.build :preview_card }
|
||||
|
||||
it 'includes empty authors array' do
|
||||
expect(subject.deep_symbolize_keys)
|
||||
.to include(
|
||||
authors: be_an(Array).and(be_empty)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when preview card has fediverse author data' do
|
||||
let(:preview_card) { Fabricate.build :preview_card, author_account: Fabricate(:account) }
|
||||
|
||||
it 'includes populated authors array' do
|
||||
expect(subject.deep_symbolize_keys)
|
||||
.to include(
|
||||
authors: be_an(Array).and(
|
||||
contain_exactly(
|
||||
include(
|
||||
account: be_present
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when preview card has non-fediverse author data' do
|
||||
let(:preview_card) { Fabricate.build :preview_card, author_name: 'Name', author_url: 'https://host.example/123' }
|
||||
|
||||
it 'includes populated authors array' do
|
||||
expect(subject.deep_symbolize_keys)
|
||||
.to include(
|
||||
authors: be_an(Array).and(
|
||||
contain_exactly(
|
||||
include(
|
||||
name: 'Name',
|
||||
url: 'https://host.example/123'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,9 +11,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
|||
[
|
||||
{ type: 'Hashtag', name: 'hoge' },
|
||||
{ type: 'Mention', href: ActivityPub::TagManager.instance.uri_for(alice) },
|
||||
{ type: 'Mention', href: bogus_mention },
|
||||
]
|
||||
end
|
||||
let(:content) { 'Hello universe' }
|
||||
let(:bogus_mention) { 'https://example.com/users/erroringuser' }
|
||||
let(:payload) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
|
@ -36,19 +38,21 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
|||
let(:media_attachments) { [] }
|
||||
|
||||
before do
|
||||
mentions.each { |a| Fabricate(:mention, status: status, account: a) }
|
||||
mentions.each { |(account, silent)| Fabricate(:mention, status: status, account: account, silent: silent) }
|
||||
tags.each { |t| status.tags << t }
|
||||
media_attachments.each { |m| status.media_attachments << m }
|
||||
stub_request(:get, bogus_mention).to_raise(HTTP::ConnectionError)
|
||||
end
|
||||
|
||||
describe '#call' do
|
||||
it 'updates text and content warning' do
|
||||
it 'updates text and content warning, and schedules re-fetching broken mention' do
|
||||
subject.call(status, json, json)
|
||||
expect(status.reload)
|
||||
.to have_attributes(
|
||||
text: eq('Hello universe'),
|
||||
spoiler_text: eq('Show more')
|
||||
)
|
||||
expect(MentionResolveWorker).to have_enqueued_sidekiq_job(status.id, bogus_mention, anything)
|
||||
end
|
||||
|
||||
context 'when the changes are only in sanitized-out HTML' do
|
||||
|
@ -320,7 +324,19 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
|||
end
|
||||
|
||||
context 'when originally with mentions' do
|
||||
let(:mentions) { [alice, bob] }
|
||||
let(:mentions) { [[alice, false], [bob, false]] }
|
||||
|
||||
before do
|
||||
subject.call(status, json, json)
|
||||
end
|
||||
|
||||
it 'updates mentions' do
|
||||
expect(status.active_mentions.reload.map(&:account_id)).to eq [alice.id]
|
||||
end
|
||||
end
|
||||
|
||||
context 'when originally with silent mentions' do
|
||||
let(:mentions) { [[alice, true], [bob, true]] }
|
||||
|
||||
before do
|
||||
subject.call(status, json, json)
|
||||
|
|
|
@ -199,6 +199,14 @@ RSpec.describe UpdateStatusService do
|
|||
.to eq [bob.id]
|
||||
expect(status.mentions.pluck(:account_id))
|
||||
.to contain_exactly(alice.id, bob.id)
|
||||
|
||||
# Going back when a mention was switched to silence should still be possible
|
||||
subject.call(status, status.account_id, text: 'Hello @alice')
|
||||
|
||||
expect(status.active_mentions.pluck(:account_id))
|
||||
.to eq [alice.id]
|
||||
expect(status.mentions.pluck(:account_id))
|
||||
.to contain_exactly(alice.id, bob.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ RSpec.describe Scheduler::UserCleanupScheduler do
|
|||
let!(:old_unconfirmed_user) { Fabricate(:user) }
|
||||
let!(:confirmed_user) { Fabricate(:user) }
|
||||
let!(:moderation_note) { Fabricate(:account_moderation_note, account: Fabricate(:account), target_account: old_unconfirmed_user.account) }
|
||||
let!(:webauthn_credential) { Fabricate(:webauthn_credential, user_id: old_unconfirmed_user.id) }
|
||||
|
||||
describe '#perform' do
|
||||
before do
|
||||
|
@ -26,6 +27,8 @@ RSpec.describe Scheduler::UserCleanupScheduler do
|
|||
.from(true).to(false)
|
||||
expect { moderation_note.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect { webauthn_credential.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect_preservation_of(new_unconfirmed_user)
|
||||
expect_preservation_of(confirmed_user)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue