Merge remote-tracking branch 'parent/main' into upstream-20240624
This commit is contained in:
commit
af2727387e
88 changed files with 703 additions and 597 deletions
17
spec/fixtures/requests/low_confidence_latin1.txt
vendored
Normal file
17
spec/fixtures/requests/low_confidence_latin1.txt
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
HTTP/1.1 200 OK
|
||||
server: nginx
|
||||
date: Thu, 13 Jun 2024 14:33:13 GMT
|
||||
content-type: text/html; charset=ISO-8859-1
|
||||
content-length: 158
|
||||
accept-ranges: bytes
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Tofu á l'orange</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Tofu á l'orange</h2>
|
||||
</body>
|
||||
</html>
|
|
@ -28,14 +28,6 @@ describe CacheBuster do
|
|||
end
|
||||
|
||||
context 'when using default options' do
|
||||
around do |example|
|
||||
# Disables the CacheBuster.new deprecation warning about default arguments.
|
||||
# Remove this `silence` block when default arg support is removed from CacheBuster
|
||||
Rails.application.deprecators[:mastodon].silence do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
|
||||
include_examples 'makes_request'
|
||||
end
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ describe Extractor do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'extract_cashtags_with_indices' do
|
||||
it 'returns []' do
|
||||
describe 'extract_entities_with_indices' do
|
||||
it 'returns empty array when cashtag present' do
|
||||
text = '$cashtag'
|
||||
extracted = described_class.extract_cashtags_with_indices(text)
|
||||
extracted = described_class.extract_entities_with_indices(text)
|
||||
expect(extracted).to eq []
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,11 +7,28 @@ describe 'Admin Measures' do
|
|||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:params) do
|
||||
{
|
||||
keys: %w(instance_accounts instance_follows instance_followers),
|
||||
instance_accounts: {
|
||||
domain: 'mastodon.social',
|
||||
include_subdomains: true,
|
||||
},
|
||||
instance_follows: {
|
||||
domain: 'mastodon.social',
|
||||
include_subdomains: true,
|
||||
},
|
||||
instance_followers: {
|
||||
domain: 'mastodon.social',
|
||||
include_subdomains: true,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
describe 'GET /api/v1/admin/measures' do
|
||||
context 'when not authorized' do
|
||||
it 'returns http forbidden' do
|
||||
post '/api/v1/admin/measures', params: { account_id: account.id, limit: 2 }
|
||||
post '/api/v1/admin/measures', params: params
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(403)
|
||||
|
@ -22,7 +39,7 @@ describe 'Admin Measures' do
|
|||
let(:scopes) { 'admin:read' }
|
||||
|
||||
it 'returns http success and status json' do
|
||||
post '/api/v1/admin/measures', params: { account_id: account.id, limit: 2 }, headers: headers
|
||||
post '/api/v1/admin/measures', params: params, headers: headers
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
|
|
|
@ -28,6 +28,7 @@ RSpec.describe FetchLinkCardService do
|
|||
stub_request(:get, 'http://example.com/sjis_with_wrong_charset').to_return(request_fixture('sjis_with_wrong_charset.txt'))
|
||||
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'))
|
||||
|
||||
Rails.cache.write('oembed_endpoint:example.com', oembed_cache) if oembed_cache
|
||||
|
||||
|
@ -150,6 +151,14 @@ RSpec.describe FetchLinkCardService do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with a URL of a page in ISO-8859-1 encoding, that charlock_holmes cannot detect' do
|
||||
let(:status) { Fabricate(:status, text: 'Check out http://example.com/low_confidence_latin1') }
|
||||
|
||||
it 'decodes the HTML' do
|
||||
expect(status.preview_card.title).to eq("Tofu á l'orange")
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a Japanese path URL' do
|
||||
let(:status) { Fabricate(:status, text: 'テストhttp://example.com/日本語') }
|
||||
|
||||
|
|
|
@ -6,3 +6,14 @@ RSpec::Matchers.define :match_json_schema do |schema|
|
|||
JSON::Validator.validate(schema_path, input_json, validate_schema: true)
|
||||
end
|
||||
end
|
||||
|
||||
RSpec::Matchers.define :match_json_values do |values|
|
||||
match do |string|
|
||||
expect(json_str_to_hash(string))
|
||||
.to include(values)
|
||||
end
|
||||
|
||||
failure_message do |value|
|
||||
"expected that #{value} would have the same values as #{values}."
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,9 +80,6 @@ end
|
|||
RSpec.configure do |config|
|
||||
config.before :suite do
|
||||
if streaming_examples_present?
|
||||
# Compile assets
|
||||
Webpacker.compile
|
||||
|
||||
# Start the node streaming server
|
||||
streaming_server_manager.start(port: STREAMING_PORT)
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ describe ActivityPub::DistributePollUpdateWorker do
|
|||
end
|
||||
|
||||
it 'delivers to followers' do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), account.id, 'http://example.com']]) do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), account.id, 'http://example.com']]) do
|
||||
subject.perform(status.id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ describe ActivityPub::DistributionWorker do
|
|||
end
|
||||
|
||||
it 'delivers to followers' do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything]]) do
|
||||
subject.perform(status.id)
|
||||
end
|
||||
end
|
||||
|
@ -43,7 +43,7 @@ describe ActivityPub::DistributionWorker do
|
|||
end
|
||||
|
||||
it 'delivers to followers' do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything]]) do
|
||||
subject.perform(status.id)
|
||||
end
|
||||
end
|
||||
|
@ -104,7 +104,7 @@ describe ActivityPub::DistributionWorker do
|
|||
end
|
||||
|
||||
it 'delivers to mentioned accounts' do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'https://foo.bar/inbox', anything]]) do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'https://foo.bar/inbox', anything]]) do
|
||||
subject.perform(status.id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,12 +16,16 @@ describe ActivityPub::MoveDistributionWorker do
|
|||
end
|
||||
|
||||
it 'delivers to followers and known blockers' do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [
|
||||
[kind_of(String), migration.account.id, 'http://example.com'],
|
||||
[kind_of(String), migration.account.id, 'http://example2.com'],
|
||||
]) do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, expected_migration_deliveries) do
|
||||
subject.perform(migration.id)
|
||||
end
|
||||
end
|
||||
|
||||
def expected_migration_deliveries
|
||||
[
|
||||
[match_json_values(type: 'Move'), migration.account.id, 'http://example.com'],
|
||||
[match_json_values(type: 'Move'), migration.account.id, 'http://example2.com'],
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ describe ActivityPub::StatusUpdateDistributionWorker do
|
|||
end
|
||||
|
||||
it 'delivers to followers' do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), status.account.id, 'http://example.com', anything]]) do
|
||||
subject.perform(status.id)
|
||||
end
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ describe ActivityPub::StatusUpdateDistributionWorker do
|
|||
end
|
||||
|
||||
it 'delivers to followers' do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), status.account.id, 'http://example.com', anything]]) do
|
||||
subject.perform(status.id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ describe ActivityPub::UpdateDistributionWorker do
|
|||
end
|
||||
|
||||
it 'delivers to followers' do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), account.id, 'http://example.com', anything]]) do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), account.id, 'http://example.com', anything]]) do
|
||||
subject.perform(account.id)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue