Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `.github/dependabot.yml`: Upstream made changes while we have dropped this file. Keep the file deleted. - `.prettierignore`: Upstream made changes at the end of the file, where we had our extra lines. Just moved our extra lines back at the end. - `app/serializers/initial_state_serializer.rb`: Upstream code style changes. Applied them. - `app/services/backup_service.rb`: Upstream code style changes. Applied them.
This commit is contained in:
@ -82,10 +82,10 @@ RSpec.describe ActivityPub::Activity::Announce do
|
||||
content: 'Lorem ipsum',
|
||||
attributedTo: 'https://example.com/actor',
|
||||
to: {
|
||||
'type': 'OrderedCollection',
|
||||
'id': 'http://example.com/followers',
|
||||
'first': 'http://example.com/followers?page=true',
|
||||
}
|
||||
type: 'OrderedCollection',
|
||||
id: 'http://example.com/followers',
|
||||
first: 'http://example.com/followers?page=true',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -252,10 +252,10 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
type: 'Note',
|
||||
content: 'Lorem ipsum',
|
||||
to: {
|
||||
'type': 'OrderedCollection',
|
||||
'id': 'http://example.com/followers',
|
||||
'first': 'http://example.com/followers?page=true',
|
||||
}
|
||||
type: 'OrderedCollection',
|
||||
id: 'http://example.com/followers',
|
||||
first: 'http://example.com/followers?page=true',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
@ -454,7 +454,6 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'with media attachments with long description' do
|
||||
let(:object_json) do
|
||||
{
|
||||
@ -733,7 +732,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
replies: {
|
||||
type: 'Collection',
|
||||
totalItems: 3,
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
@ -763,7 +762,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
type: 'Note',
|
||||
name: 'Yellow',
|
||||
inReplyTo: ActivityPub::TagManager.instance.uri_for(local_status)
|
||||
inReplyTo: ActivityPub::TagManager.instance.uri_for(local_status),
|
||||
}
|
||||
end
|
||||
|
||||
@ -788,7 +787,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
type: 'Note',
|
||||
name: 'Yellow',
|
||||
inReplyTo: ActivityPub::TagManager.instance.uri_for(local_status)
|
||||
inReplyTo: ActivityPub::TagManager.instance.uri_for(local_status),
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -110,7 +110,7 @@ RSpec.describe ActivityPub::Activity::Flag do
|
||||
|
||||
describe '#perform with a defined uri' do
|
||||
subject { described_class.new(json, sender) }
|
||||
let (:flag_id) { 'http://example.com/reports/1' }
|
||||
let(:flag_id) { 'http://example.com/reports/1' }
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
|
@ -20,7 +20,7 @@ describe Extractor do
|
||||
text = '@screen_name'
|
||||
extracted = Extractor.extract_mentions_or_lists_with_indices(text)
|
||||
expect(extracted).to eq [
|
||||
{ screen_name: 'screen_name', indices: [ 0, 12 ] }
|
||||
{ screen_name: 'screen_name', indices: [0, 12] },
|
||||
]
|
||||
end
|
||||
|
||||
@ -44,19 +44,19 @@ describe Extractor do
|
||||
it 'does not exclude normal hash text before ://' do
|
||||
text = '#hashtag://'
|
||||
extracted = Extractor.extract_hashtags_with_indices(text)
|
||||
expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ]
|
||||
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
|
||||
end
|
||||
|
||||
it 'excludes http://' do
|
||||
text = '#hashtaghttp://'
|
||||
extracted = Extractor.extract_hashtags_with_indices(text)
|
||||
expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ]
|
||||
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
|
||||
end
|
||||
|
||||
it 'excludes https://' do
|
||||
text = '#hashtaghttps://'
|
||||
extracted = Extractor.extract_hashtags_with_indices(text)
|
||||
expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ]
|
||||
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
|
||||
end
|
||||
|
||||
it 'yields hashtags if a block is given' do
|
||||
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||
|
||||
describe FastIpMap do
|
||||
describe '#include?' do
|
||||
subject { described_class.new([IPAddr.new('20.4.0.0/16'), IPAddr.new('145.22.30.0/24'), IPAddr.new('189.45.86.3')])}
|
||||
subject { described_class.new([IPAddr.new('20.4.0.0/16'), IPAddr.new('145.22.30.0/24'), IPAddr.new('189.45.86.3')]) }
|
||||
|
||||
it 'returns true for an exact match' do
|
||||
expect(subject.include?(IPAddr.new('189.45.86.3'))).to be true
|
||||
|
@ -423,7 +423,7 @@ RSpec.describe FeedManager do
|
||||
|
||||
FeedManager.instance.merge_into_home(account, reblog.account)
|
||||
|
||||
expect(redis.zscore("feed:home:0", reblog.id)).to eq nil
|
||||
expect(redis.zscore('feed:home:0', reblog.id)).to eq nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -39,17 +39,17 @@ RSpec.describe LinkDetailsExtractor do
|
||||
let(:original_url) { 'https://example.com/page.html' }
|
||||
|
||||
context 'and is wrapped in CDATA tags' do
|
||||
let(:html) { <<-HTML }
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="application/ld+json">
|
||||
//<![CDATA[
|
||||
{"@context":"http://schema.org","@type":"NewsArticle","mainEntityOfPage":"https://example.com/page.html","headline":"Foo","datePublished":"2022-01-31T19:53:00+00:00","url":"https://example.com/page.html","description":"Bar","author":{"@type":"Person","name":"Hoge"},"publisher":{"@type":"Organization","name":"Baz"}}
|
||||
//]]>
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
||||
let(:html) { <<~HTML }
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="application/ld+json">
|
||||
//<![CDATA[
|
||||
{"@context":"http://schema.org","@type":"NewsArticle","mainEntityOfPage":"https://example.com/page.html","headline":"Foo","datePublished":"2022-01-31T19:53:00+00:00","url":"https://example.com/page.html","description":"Bar","author":{"@type":"Person","name":"Hoge"},"publisher":{"@type":"Organization","name":"Baz"}}
|
||||
//]]>
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
describe '#title' do
|
||||
@ -78,57 +78,57 @@ RSpec.describe LinkDetailsExtractor do
|
||||
end
|
||||
|
||||
context 'but the first tag is invalid JSON' do
|
||||
let(:html) { <<-HTML }
|
||||
<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context":"https://schema.org",
|
||||
"@type":"ItemList",
|
||||
"url":"https://example.com/page.html",
|
||||
"name":"Foo",
|
||||
"description":"Bar"
|
||||
},
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BreadcrumbList",
|
||||
"itemListElement":[
|
||||
{
|
||||
"@type":"ListItem",
|
||||
"position":1,
|
||||
"item":{
|
||||
"@id":"https://www.example.com",
|
||||
"name":"Baz"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
</script>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context":"https://schema.org",
|
||||
"@type":"NewsArticle",
|
||||
"mainEntityOfPage": {
|
||||
"@type":"WebPage",
|
||||
"@id": "http://example.com/page.html"
|
||||
},
|
||||
"headline": "Foo",
|
||||
"description": "Bar",
|
||||
"datePublished": "2022-01-31T19:46:00+00:00",
|
||||
"author": {
|
||||
"@type": "Organization",
|
||||
"name": "Hoge"
|
||||
},
|
||||
"publisher": {
|
||||
"@type": "NewsMediaOrganization",
|
||||
"name":"Baz",
|
||||
"url":"https://example.com/"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
let(:html) { <<~HTML }
|
||||
<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context":"https://schema.org",
|
||||
"@type":"ItemList",
|
||||
"url":"https://example.com/page.html",
|
||||
"name":"Foo",
|
||||
"description":"Bar"
|
||||
},
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BreadcrumbList",
|
||||
"itemListElement":[
|
||||
{
|
||||
"@type":"ListItem",
|
||||
"position":1,
|
||||
"item":{
|
||||
"@id":"https://www.example.com",
|
||||
"name":"Baz"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
</script>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context":"https://schema.org",
|
||||
"@type":"NewsArticle",
|
||||
"mainEntityOfPage": {
|
||||
"@type":"WebPage",
|
||||
"@id": "http://example.com/page.html"
|
||||
},
|
||||
"headline": "Foo",
|
||||
"description": "Bar",
|
||||
"datePublished": "2022-01-31T19:46:00+00:00",
|
||||
"author": {
|
||||
"@type": "Organization",
|
||||
"name": "Hoge"
|
||||
},
|
||||
"publisher": {
|
||||
"@type": "NewsMediaOrganization",
|
||||
"name":"Baz",
|
||||
"url":"https://example.com/"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
describe '#title' do
|
||||
|
@ -43,7 +43,7 @@ describe Request do
|
||||
before { stub_request(:get, 'http://example.com') }
|
||||
|
||||
it 'executes a HTTP request' do
|
||||
expect { |block| subject.perform &block }.to yield_control
|
||||
expect { |block| subject.perform(&block) }.to yield_control
|
||||
expect(a_request(:get, 'http://example.com')).to have_been_made.once
|
||||
end
|
||||
|
||||
@ -54,18 +54,18 @@ describe Request do
|
||||
allow(resolver).to receive(:timeouts=).and_return(nil)
|
||||
allow(Resolv::DNS).to receive(:open).and_yield(resolver)
|
||||
|
||||
expect { |block| subject.perform &block }.to yield_control
|
||||
expect { |block| subject.perform(&block) }.to yield_control
|
||||
expect(a_request(:get, 'http://example.com')).to have_been_made.once
|
||||
end
|
||||
|
||||
it 'sets headers' do
|
||||
expect { |block| subject.perform &block }.to yield_control
|
||||
expect { |block| subject.perform(&block) }.to yield_control
|
||||
expect(a_request(:get, 'http://example.com').with(headers: subject.headers)).to have_been_made
|
||||
end
|
||||
|
||||
it 'closes underlying connection' do
|
||||
expect_any_instance_of(HTTP::Client).to receive(:close)
|
||||
expect { |block| subject.perform &block }.to yield_control
|
||||
expect { |block| subject.perform(&block) }.to yield_control
|
||||
end
|
||||
|
||||
it 'returns response which implements body_with_limit' do
|
||||
|
@ -10,7 +10,7 @@ RSpec.describe Settings::Extend do
|
||||
describe '#settings' do
|
||||
it 'sets @settings as an instance of Settings::ScopedSettings' do
|
||||
user = Fabricate(:user)
|
||||
expect(user.settings).to be_kind_of Settings::ScopedSettings
|
||||
expect(user.settings).to be_a Settings::ScopedSettings
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -32,6 +32,7 @@ describe StatusFilter do
|
||||
|
||||
context 'with real account' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
subject { described_class.new(status, account) }
|
||||
|
||||
context 'when there are no connections' do
|
||||
|
@ -223,7 +223,7 @@ RSpec.describe TextFormatter do
|
||||
end
|
||||
|
||||
context 'given a URL containing unsafe code (XSS attack, visible part)' do
|
||||
let(:text) { %q{http://example.com/b<del>b</del>} }
|
||||
let(:text) { 'http://example.com/b<del>b</del>' }
|
||||
|
||||
it 'does not include the HTML in the URL' do
|
||||
is_expected.to include '"http://example.com/b"'
|
||||
@ -235,7 +235,7 @@ RSpec.describe TextFormatter do
|
||||
end
|
||||
|
||||
context 'given a URL containing unsafe code (XSS attack, invisible part)' do
|
||||
let(:text) { %q{http://example.com/blahblahblahblah/a<script>alert("Hello")</script>} }
|
||||
let(:text) { 'http://example.com/blahblahblahblah/a<script>alert("Hello")</script>' }
|
||||
|
||||
it 'does not include the HTML in the URL' do
|
||||
is_expected.to include '"http://example.com/blahblahblahblah/a"'
|
||||
|
@ -14,9 +14,9 @@ describe WebfingerResource do
|
||||
it 'raises with a route whose controller is not AccountsController' do
|
||||
resource = 'https://example.com/users/alice/other'
|
||||
|
||||
expect {
|
||||
expect do
|
||||
WebfingerResource.new(resource).username
|
||||
}.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'raises with a route whose action is not show' do
|
||||
@ -29,17 +29,17 @@ describe WebfingerResource do
|
||||
|
||||
expect(Rails.application.routes).to receive(:recognize_path).with(resource).and_return(recognized).at_least(:once)
|
||||
|
||||
expect {
|
||||
expect do
|
||||
WebfingerResource.new(resource).username
|
||||
}.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'raises with a string that doesnt start with URL' do
|
||||
resource = 'website for http://example.com/users/alice/other'
|
||||
|
||||
expect {
|
||||
expect do
|
||||
WebfingerResource.new(resource).username
|
||||
}.to raise_error(WebfingerResource::InvalidRequest)
|
||||
end.to raise_error(WebfingerResource::InvalidRequest)
|
||||
end
|
||||
|
||||
it 'finds the username in a valid https route' do
|
||||
@ -68,9 +68,9 @@ describe WebfingerResource do
|
||||
it 'raises on a non-local domain' do
|
||||
resource = 'user@remote-host.com'
|
||||
|
||||
expect {
|
||||
expect do
|
||||
WebfingerResource.new(resource).username
|
||||
}.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'finds username for a local domain' do
|
||||
@ -94,17 +94,17 @@ describe WebfingerResource do
|
||||
it 'raises on a non-local domain' do
|
||||
resource = 'acct:user@remote-host.com'
|
||||
|
||||
expect {
|
||||
expect do
|
||||
WebfingerResource.new(resource).username
|
||||
}.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'raises on a nonsense domain' do
|
||||
resource = 'acct:user@remote-host@remote-hostess.remote.local@remote'
|
||||
|
||||
expect {
|
||||
expect do
|
||||
WebfingerResource.new(resource).username
|
||||
}.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'finds the username for a local account if the domain is the local one' do
|
||||
@ -128,9 +128,9 @@ describe WebfingerResource do
|
||||
it 'raises InvalidRequest' do
|
||||
resource = 'df/:dfkj'
|
||||
|
||||
expect {
|
||||
expect do
|
||||
WebfingerResource.new(resource).username
|
||||
}.to raise_error(WebfingerResource::InvalidRequest)
|
||||
end.to raise_error(WebfingerResource::InvalidRequest)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user