Merge remote-tracking branch 'parent/main' into upstream-20241206
This commit is contained in:
commit
3c3ee557d0
187 changed files with 1105 additions and 537 deletions
|
@ -1,5 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:setting) do
|
||||
var 'var'
|
||||
var { sequence(:var) { |n| "var_#{n}" } }
|
||||
end
|
||||
|
|
5
spec/fabricators/tag_trend_fabricator.rb
Normal file
5
spec/fabricators/tag_trend_fabricator.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:tag_trend) do
|
||||
tag
|
||||
end
|
|
@ -91,6 +91,7 @@ RSpec.describe AdminMailer do
|
|||
before do
|
||||
PreviewCardTrend.create!(preview_card: link)
|
||||
StatusTrend.create!(status: status, account: Fabricate(:account))
|
||||
TagTrend.create!(tag: tag)
|
||||
recipient.user.update(locale: :en)
|
||||
end
|
||||
|
||||
|
|
11
spec/models/tag_trend_spec.rb
Normal file
11
spec/models/tag_trend_spec.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe TagTrend do
|
||||
include_examples 'RankedTrend'
|
||||
|
||||
describe 'Associations' do
|
||||
it { is_expected.to belong_to(:tag).required }
|
||||
end
|
||||
end
|
|
@ -88,10 +88,10 @@ RSpec.describe Trends::Tags do
|
|||
|
||||
it 'decays scores' do
|
||||
subject.refresh(yesterday + 12.hours)
|
||||
original_score = subject.score(tag_ocs.id)
|
||||
original_score = TagTrend.find_by(tag: tag_ocs).score
|
||||
expect(original_score).to eq 144.0
|
||||
subject.refresh(yesterday + 12.hours + subject.options[:max_score_halflife])
|
||||
decayed_score = subject.score(tag_ocs.id)
|
||||
decayed_score = TagTrend.find_by(tag: tag_ocs).score
|
||||
expect(decayed_score).to be <= original_score / 2
|
||||
end
|
||||
end
|
||||
|
|
|
@ -55,6 +55,9 @@ RSpec.describe 'Instances' do
|
|||
max_characters: StatusLengthValidator::MAX_CHARS,
|
||||
max_media_attachments: Status::MEDIA_ATTACHMENTS_LIMIT
|
||||
),
|
||||
media_attachments: include(
|
||||
description_limit: MediaAttachment::MAX_DESCRIPTION_LENGTH
|
||||
),
|
||||
polls: include(
|
||||
max_options: PollValidator::MAX_OPTIONS
|
||||
)
|
||||
|
|
|
@ -7,6 +7,29 @@ RSpec.describe 'Tags' do
|
|||
context 'when tag exists' do
|
||||
let(:tag) { Fabricate :tag }
|
||||
|
||||
context 'with HTML format' do
|
||||
before { get tag_path(tag) }
|
||||
|
||||
it 'returns page with links to alternate resources' do
|
||||
expect(rss_links.first[:href])
|
||||
.to eq(tag_url(tag))
|
||||
expect(activity_json_links.first[:href])
|
||||
.to eq(tag_url(tag))
|
||||
end
|
||||
|
||||
def rss_links
|
||||
alternate_links.css('[type="application/rss+xml"]')
|
||||
end
|
||||
|
||||
def activity_json_links
|
||||
alternate_links.css('[type="application/activity+json"]')
|
||||
end
|
||||
|
||||
def alternate_links
|
||||
response.parsed_body.css('link[rel=alternate]')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with JSON format' do
|
||||
before { get tag_path(tag, format: :json) }
|
||||
|
||||
|
|
41
spec/serializers/rest/preview_card_serializer_spec.rb
Normal file
41
spec/serializers/rest/preview_card_serializer_spec.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
# 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 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
|
|
@ -7,10 +7,12 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
|||
|
||||
let(:thread) { nil }
|
||||
let!(:status) { Fabricate(:status, text: 'Hello world', account: Fabricate(:account, domain: 'example.com'), thread: thread) }
|
||||
let(:bogus_mention) { 'https://example.com/users/erroringuser' }
|
||||
let(:json_tags) do
|
||||
[
|
||||
{ type: 'Hashtag', name: 'hoge' },
|
||||
{ type: 'Mention', href: ActivityPub::TagManager.instance.uri_for(alice) },
|
||||
{ type: 'Mention', href: bogus_mention },
|
||||
]
|
||||
end
|
||||
let(:content) { 'Hello universe' }
|
||||
|
@ -39,16 +41,18 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
|||
mentions.each { |a| Fabricate(:mention, status: status, account: a) }
|
||||
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
|
||||
|
|
|
@ -70,7 +70,7 @@ RSpec.describe PostStatusService do
|
|||
subject.call(account, text: 'Hi future!', scheduled_at: invalid_scheduled_time)
|
||||
end.to raise_error(
|
||||
ActiveRecord::RecordInvalid,
|
||||
'Validation failed: Scheduled at The scheduled date must be in the future'
|
||||
'Validation failed: Scheduled at date must be in the future'
|
||||
)
|
||||
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