Merge remote-tracking branch 'parent/main' into upstream-20240628

This commit is contained in:
KMY 2024-06-28 08:57:12 +09:00
commit 6955843321
178 changed files with 1924 additions and 1178 deletions

View file

@ -33,7 +33,7 @@ describe Admin::StatusesController do
context 'when filtering by media' do
before do
get :index, params: { account_id: account.id, media: '1' }
get :index, params: { account_id: account.id, media: true }
end
it 'returns http success' do
@ -44,6 +44,11 @@ describe Admin::StatusesController do
describe 'GET #show' do
before do
status.media_attachments << Fabricate(:media_attachment, type: :image, account: status.account)
status.save!
status.snapshot!(at_time: status.created_at, rate_limit: false)
status.update!(text: 'Hello, this is an edited post')
status.snapshot!(rate_limit: false)
get :show, params: { account_id: account.id, id: status.id }
end

View file

@ -0,0 +1,5 @@
HTTP/1.1 301 Moved Permanently
server: nginx
date: Thu, 27 Jun 2024 11:04:53 GMT
content-type: text/html; charset=UTF-8
location: http://example.com/ärgerliche-umlaute.html

12
spec/flatware_helper.rb Normal file
View file

@ -0,0 +1,12 @@
# frozen_string_literal: true
if defined?(Flatware)
Flatware.configure do |config|
config.after_fork do |test_env_number|
unless ENV.fetch('DISABLE_SIMPLECOV', nil) == 'true'
require 'simplecov'
SimpleCov.at_fork.call(test_env_number) # Combines parallel coverage results
end
end
end
end

View file

@ -210,10 +210,14 @@ RSpec.describe MediaAttachment, :paperclip_processing do
expect(media.file.meta['original']['duration']).to be_within(0.05).of(0.235102)
expect(media.thumbnail.present?).to be true
# NOTE: Our libvips and ImageMagick implementations currently have different results
expect(media.file.meta['colors']['background']).to eq(ENV['MASTODON_USE_LIBVIPS'] ? '#268cd9' : '#3088d4')
expect(media.file.meta['colors']['background']).to eq(expected_background_color)
expect(media.file_file_name).to_not eq 'boop.ogg'
end
def expected_background_color
# The libvips and ImageMagick implementations produce different results
Rails.configuration.x.use_vips ? '#268cd9' : '#3088d4'
end
end
describe 'mp3 with large cover art' do

View file

@ -9,7 +9,7 @@ describe 'The account show page' do
get '/@alice'
expect(head_link_icons.size).to eq(4) # One general favicon and three with sizes
expect(head_link_icons.size).to eq(3) # Three favicons with sizes
expect(head_meta_content('og:title')).to match alice.display_name
expect(head_meta_content('og:type')).to eq 'profile'

View file

@ -29,6 +29,7 @@ RSpec.describe FetchLinkCardService do
stub_request(:get, 'http://example.com/koi8-r').to_return(request_fixture('koi8-r.txt'))
stub_request(:get, 'http://example.com/windows-1251').to_return(request_fixture('windows-1251.txt'))
stub_request(:get, 'http://example.com/low_confidence_latin1').to_return(request_fixture('low_confidence_latin1.txt'))
stub_request(:get, 'http://example.com/aergerliche-umlaute').to_return(request_fixture('redirect_with_utf8_url.txt'))
Rails.cache.write('oembed_endpoint:example.com', oembed_cache) if oembed_cache
@ -103,6 +104,14 @@ RSpec.describe FetchLinkCardService do
end
end
context 'with a redirect URL with faulty encoding' do
let(:status) { Fabricate(:status, text: 'http://example.com/aergerliche-umlaute') }
it 'does not create a preview card' do
expect(status.preview_card).to be_nil
end
end
context 'with a 404 URL' do
let(:status) { Fabricate(:status, text: 'http://example.com/not-found') }
@ -195,6 +204,19 @@ RSpec.describe FetchLinkCardService do
end
end
context 'with an URL too long for PostgreSQL unique indexes' do
let(:url) { "http://example.com/#{'a' * 2674}" }
let(:status) { Fabricate(:status, text: url) }
it 'does not fetch the URL' do
expect(a_request(:get, url)).to_not have_been_made
end
it 'does not create a preview card' do
expect(status.preview_card).to be_nil
end
end
context 'with a URL of a page with oEmbed support' do
let(:html) { '<!doctype html><title>Hello world</title><link rel="alternate" type="application/json+oembed" href="http://example.com/oembed?url=http://example.com/html">' }
let(:status) { Fabricate(:status, text: 'http://example.com/html') }

View file

@ -2,7 +2,14 @@
RSpec.configure do |config|
config.after(:each, :js, type: :system) do
errors = page.driver.browser.logs.get(:browser)
# Classes of intermittent ignorable errors
ignored_errors = [
/Error while trying to use the following icon from the Manifest/, # https://github.com/mastodon/mastodon/pull/30793
]
errors = page.driver.browser.logs.get(:browser).reject do |error|
ignored_errors.any? { |pattern| pattern.match(error.message) }
end
if errors.present?
aggregate_failures 'javascript errrors' do
errors.each do |error|