Merge commit '9e04007020
' into upstream-20240725
This commit is contained in:
commit
a99f174d98
322 changed files with 8093 additions and 1586 deletions
|
@ -36,6 +36,7 @@ RSpec.describe ActivityPub::Activity::Flag do
|
|||
expect(report).to_not be_nil
|
||||
expect(report.comment).to eq 'Boo!!'
|
||||
expect(report.status_ids).to eq [status.id]
|
||||
expect(report.application).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Move do
|
||||
RSpec::Matchers.define_negated_matcher :not_be_following, :be_following
|
||||
RSpec::Matchers.define_negated_matcher :not_be_requested, :be_requested
|
||||
|
||||
let(:follower) { Fabricate(:account) }
|
||||
let(:old_account) { Fabricate(:account, uri: 'https://example.org/alice', domain: 'example.org', protocol: :activitypub, inbox_url: 'https://example.org/inbox') }
|
||||
let(:new_account) { Fabricate(:account, uri: 'https://example.com/alice', domain: 'example.com', protocol: :activitypub, inbox_url: 'https://example.com/inbox', also_known_as: also_known_as) }
|
||||
|
@ -39,48 +42,36 @@ RSpec.describe ActivityPub::Activity::Move do
|
|||
end
|
||||
|
||||
context 'when all conditions are met', :inline_jobs do
|
||||
it 'sets moved account on old account' do
|
||||
expect(old_account.reload.moved_to_account_id).to eq new_account.id
|
||||
end
|
||||
|
||||
it 'makes followers unfollow old account' do
|
||||
expect(follower.following?(old_account)).to be false
|
||||
end
|
||||
|
||||
it 'makes followers follow-request the new account' do
|
||||
expect(follower.requested?(new_account)).to be true
|
||||
it 'sets moved on old account, followers unfollow old account, followers request the new account' do
|
||||
expect(old_account.reload.moved_to_account_id)
|
||||
.to eq new_account.id
|
||||
expect(follower)
|
||||
.to not_be_following(old_account)
|
||||
.and be_requested(new_account)
|
||||
end
|
||||
end
|
||||
|
||||
context "when the new account can't be resolved" do
|
||||
let(:returned_account) { nil }
|
||||
|
||||
it 'does not set moved account on old account' do
|
||||
expect(old_account.reload.moved_to_account_id).to be_nil
|
||||
end
|
||||
|
||||
it 'does not make followers unfollow old account' do
|
||||
expect(follower.following?(old_account)).to be true
|
||||
end
|
||||
|
||||
it 'does not make followers follow-request the new account' do
|
||||
expect(follower.requested?(new_account)).to be false
|
||||
it 'does not set moved on old account, does not unfollow old, does not follow request new' do
|
||||
expect(old_account.reload.moved_to_account_id)
|
||||
.to be_nil
|
||||
expect(follower)
|
||||
.to be_following(old_account)
|
||||
.and not_be_requested(new_account)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the new account does not references the old account' do
|
||||
let(:also_known_as) { [] }
|
||||
|
||||
it 'does not set moved account on old account' do
|
||||
expect(old_account.reload.moved_to_account_id).to be_nil
|
||||
end
|
||||
|
||||
it 'does not make followers unfollow old account' do
|
||||
expect(follower.following?(old_account)).to be true
|
||||
end
|
||||
|
||||
it 'does not make followers follow-request the new account' do
|
||||
expect(follower.requested?(new_account)).to be false
|
||||
it 'does not set moved on old account, does not unfollow old, does not follow request new' do
|
||||
expect(old_account.reload.moved_to_account_id)
|
||||
.to be_nil
|
||||
expect(follower)
|
||||
.to be_following(old_account)
|
||||
.and not_be_requested(new_account)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -91,16 +82,12 @@ RSpec.describe ActivityPub::Activity::Move do
|
|||
redis.del("move_in_progress:#{old_account.id}")
|
||||
end
|
||||
|
||||
it 'does not set moved account on old account' do
|
||||
expect(old_account.reload.moved_to_account_id).to be_nil
|
||||
end
|
||||
|
||||
it 'does not make followers unfollow old account' do
|
||||
expect(follower.following?(old_account)).to be true
|
||||
end
|
||||
|
||||
it 'does not make followers follow-request the new account' do
|
||||
expect(follower.requested?(new_account)).to be false
|
||||
it 'does not set moved on old account, does not unfollow old, does not follow request new' do
|
||||
expect(old_account.reload.moved_to_account_id)
|
||||
.to be_nil
|
||||
expect(follower)
|
||||
.to be_following(old_account)
|
||||
.and not_be_requested(new_account)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -59,7 +59,7 @@ RSpec.describe ActivityPub::Adapter do
|
|||
let(:serializer_class) { TestWithBasicContextSerializer }
|
||||
|
||||
it 'renders a basic @context' do
|
||||
expect(subject).to include({ '@context' => 'https://www.w3.org/ns/activitystreams' })
|
||||
expect(subject).to include({ '@context': 'https://www.w3.org/ns/activitystreams' })
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -67,7 +67,7 @@ RSpec.describe ActivityPub::Adapter do
|
|||
let(:serializer_class) { TestWithNamedContextSerializer }
|
||||
|
||||
it 'renders a @context with both items' do
|
||||
expect(subject).to include({ '@context' => ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'] })
|
||||
expect(subject).to include({ '@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'] })
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -75,7 +75,7 @@ RSpec.describe ActivityPub::Adapter do
|
|||
let(:serializer_class) { TestWithNestedNamedContextSerializer }
|
||||
|
||||
it 'renders a @context with both items' do
|
||||
expect(subject).to include({ '@context' => ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'] })
|
||||
expect(subject).to include({ '@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'] })
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -83,7 +83,7 @@ RSpec.describe ActivityPub::Adapter do
|
|||
let(:serializer_class) { TestWithContextExtensionSerializer }
|
||||
|
||||
it 'renders a @context with the extension' do
|
||||
expect(subject).to include({ '@context' => ['https://www.w3.org/ns/activitystreams', { 'sensitive' => 'as:sensitive' }] })
|
||||
expect(subject).to include({ '@context': ['https://www.w3.org/ns/activitystreams', { 'sensitive' => 'as:sensitive' }] })
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -91,7 +91,7 @@ RSpec.describe ActivityPub::Adapter do
|
|||
let(:serializer_class) { TestWithNestedContextExtensionSerializer }
|
||||
|
||||
it 'renders a @context with both extensions' do
|
||||
expect(subject).to include({ '@context' => ['https://www.w3.org/ns/activitystreams', { 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', 'sensitive' => 'as:sensitive' }] })
|
||||
expect(subject).to include({ '@context': ['https://www.w3.org/ns/activitystreams', { 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', 'sensitive' => 'as:sensitive' }] })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
41
spec/lib/webfinger_spec.rb
Normal file
41
spec/lib/webfinger_spec.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Webfinger do
|
||||
describe 'self link' do
|
||||
context 'when self link is specified with type application/activity+json' do
|
||||
let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/activity+json' }] } }
|
||||
|
||||
it 'correctly parses the response' do
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
|
||||
response = described_class.new('acct:alice@example.com').perform
|
||||
|
||||
expect(response.self_link_href).to eq 'https://example.com/alice'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when self link is specified with type application/ld+json' do
|
||||
let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' }] } }
|
||||
|
||||
it 'correctly parses the response' do
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
|
||||
response = described_class.new('acct:alice@example.com').perform
|
||||
|
||||
expect(response.self_link_href).to eq 'https://example.com/alice'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when self link is specified with incorrect type' do
|
||||
let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/json"' }] } }
|
||||
|
||||
it 'raises an error' do
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
|
||||
expect { described_class.new('acct:alice@example.com').perform }.to raise_error(Webfinger::Error)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue