Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `.prettierignore`: Upstream added a line at the end of the file, while glitch-soc had its own extra lines. Took upstream's change. - `CONTRIBUTING.md`: We have our custom CONTRIBUTING.md quoting upstream. Upstream made changes. Ported upstream changes. - `app/controllers/application_controller.rb`: Upstream made code style changes in a method that is entirely replaced in glitch-soc. Ignored the change. - `app/models/account.rb`: Code style changes textually close to glitch-soc-specific changes. Ported upstream changes. - `lib/sanitize_ext/sanitize_config.rb`: Upstream code style changes. Ignored them.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Accept do
|
||||
@@ -42,6 +44,8 @@ RSpec.describe ActivityPub::Activity::Accept do
|
||||
end
|
||||
|
||||
context 'given a relay' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') }
|
||||
|
||||
let(:json) do
|
||||
@@ -59,8 +63,6 @@ RSpec.describe ActivityPub::Activity::Accept do
|
||||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
it 'marks the relay as accepted' do
|
||||
subject.perform
|
||||
expect(relay.reload.accepted?).to be true
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Add do
|
||||
@@ -48,10 +50,10 @@ RSpec.describe ActivityPub::Activity::Add do
|
||||
end
|
||||
|
||||
it 'fetches the status and pins it' do
|
||||
allow(service_stub).to receive(:call) do |uri, id: true, on_behalf_of: nil, request_id: nil|
|
||||
allow(service_stub).to receive(:call) do |uri, id: true, on_behalf_of: nil, request_id: nil| # rubocop:disable Lint/UnusedBlockArgument
|
||||
expect(uri).to eq 'https://example.com/unknown'
|
||||
expect(id).to eq true
|
||||
expect(on_behalf_of&.following?(sender)).to eq true
|
||||
expect(id).to be true
|
||||
expect(on_behalf_of&.following?(sender)).to be true
|
||||
status
|
||||
end
|
||||
subject.perform
|
||||
@@ -62,10 +64,10 @@ RSpec.describe ActivityPub::Activity::Add do
|
||||
|
||||
context 'when there is no local follower' do
|
||||
it 'tries to fetch the status' do
|
||||
allow(service_stub).to receive(:call) do |uri, id: true, on_behalf_of: nil, request_id: nil|
|
||||
allow(service_stub).to receive(:call) do |uri, id: true, on_behalf_of: nil, request_id: nil| # rubocop:disable Lint/UnusedBlockArgument
|
||||
expect(uri).to eq 'https://example.com/unknown'
|
||||
expect(id).to eq true
|
||||
expect(on_behalf_of).to eq nil
|
||||
expect(id).to be true
|
||||
expect(on_behalf_of).to be_nil
|
||||
nil
|
||||
end
|
||||
subject.perform
|
||||
|
@@ -1,6 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Announce do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers', uri: 'https://example.com/actor') }
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
let(:status) { Fabricate(:status, account: recipient) }
|
||||
@@ -27,8 +31,6 @@ RSpec.describe ActivityPub::Activity::Announce do
|
||||
}
|
||||
end
|
||||
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
describe '#perform' do
|
||||
context 'when sender is followed by a local account' do
|
||||
before do
|
||||
@@ -110,13 +112,13 @@ RSpec.describe ActivityPub::Activity::Announce do
|
||||
end
|
||||
|
||||
context 'when the sender is relayed' do
|
||||
subject { described_class.new(json, sender, relayed_through_actor: relay_account) }
|
||||
|
||||
let!(:relay_account) { Fabricate(:account, inbox_url: 'https://relay.example.com/inbox') }
|
||||
let!(:relay) { Fabricate(:relay, inbox_url: 'https://relay.example.com/inbox') }
|
||||
|
||||
let(:object_json) { 'https://example.com/actor/hello-world' }
|
||||
|
||||
subject { described_class.new(json, sender, relayed_through_actor: relay_account) }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json))
|
||||
end
|
||||
@@ -139,7 +141,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
||||
end
|
||||
|
||||
it 'does not fetch the remote status' do
|
||||
expect(a_request(:get, 'https://example.com/actor/hello-world')).not_to have_been_made
|
||||
expect(a_request(:get, 'https://example.com/actor/hello-world')).to_not have_been_made
|
||||
expect(Status.find_by(uri: 'https://example.com/actor/hello-world')).to be_nil
|
||||
end
|
||||
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Block do
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Create do
|
||||
@@ -51,7 +53,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.edited?).to eq true
|
||||
expect(status.edited?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -77,7 +79,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.edited?).to eq false
|
||||
expect(status.edited?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -798,11 +800,9 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
end
|
||||
|
||||
context 'with an encrypted message' do
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
let(:target_device) { Fabricate(:device, account: recipient) }
|
||||
|
||||
subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) }
|
||||
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
@@ -824,6 +824,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
},
|
||||
}
|
||||
end
|
||||
let(:target_device) { Fabricate(:device, account: recipient) }
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
@@ -878,14 +879,9 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
end
|
||||
|
||||
context 'when sender replies to local status' do
|
||||
let!(:local_status) { Fabricate(:status) }
|
||||
|
||||
subject { described_class.new(json, sender, delivery: true) }
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
let!(:local_status) { Fabricate(:status) }
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
@@ -895,6 +891,10 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
@@ -904,14 +904,9 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
end
|
||||
|
||||
context 'when sender targets a local user' do
|
||||
let!(:local_account) { Fabricate(:account) }
|
||||
|
||||
subject { described_class.new(json, sender, delivery: true) }
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
let!(:local_account) { Fabricate(:account) }
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
@@ -921,6 +916,10 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
@@ -930,14 +929,9 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
end
|
||||
|
||||
context 'when sender cc\'s a local user' do
|
||||
let!(:local_account) { Fabricate(:account) }
|
||||
|
||||
subject { described_class.new(json, sender, delivery: true) }
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
let!(:local_account) { Fabricate(:account) }
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
@@ -947,6 +941,10 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Delete do
|
||||
@@ -30,6 +32,7 @@ RSpec.describe ActivityPub::Activity::Delete do
|
||||
context 'when the status has been reblogged' do
|
||||
describe '#perform' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
let!(:reblogger) { Fabricate(:account) }
|
||||
let!(:follower) { Fabricate(:account, username: 'follower', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
||||
let!(:reblog) { Fabricate(:status, account: reblogger, reblog: status) }
|
||||
@@ -53,6 +56,7 @@ RSpec.describe ActivityPub::Activity::Delete do
|
||||
context 'when the status has been reported' do
|
||||
describe '#perform' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
let!(:reporter) { Fabricate(:account) }
|
||||
|
||||
before do
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Flag do
|
||||
@@ -110,6 +112,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' }
|
||||
|
||||
before do
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Follow do
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Like do
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Move do
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Reject do
|
||||
@@ -121,6 +123,8 @@ RSpec.describe ActivityPub::Activity::Reject do
|
||||
end
|
||||
|
||||
context 'given a relay' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') }
|
||||
|
||||
let(:json) do
|
||||
@@ -138,8 +142,6 @@ RSpec.describe ActivityPub::Activity::Reject do
|
||||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
it 'marks the relay as rejected' do
|
||||
subject.perform
|
||||
expect(relay.reload.rejected?).to be true
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Remove do
|
||||
|
@@ -1,6 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Undo do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
let(:sender) { Fabricate(:account, domain: 'example.com') }
|
||||
|
||||
let(:json) do
|
||||
@@ -13,8 +17,6 @@ RSpec.describe ActivityPub::Activity::Undo do
|
||||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
describe '#perform' do
|
||||
context 'with Announce' do
|
||||
let(:status) { Fabricate(:status) }
|
||||
|
@@ -1,14 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Update do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
let!(:sender) { Fabricate(:account) }
|
||||
|
||||
before do
|
||||
sender.update!(uri: ActivityPub::TagManager.instance.uri_for(sender))
|
||||
end
|
||||
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
describe '#perform' do
|
||||
context 'with an Actor object' do
|
||||
let(:modified_sender) do
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Adapter do
|
||||
@@ -41,10 +43,10 @@ RSpec.describe ActivityPub::Adapter do
|
||||
end
|
||||
|
||||
describe '#serializable_hash' do
|
||||
let(:serializer_class) {}
|
||||
|
||||
subject { ActiveModelSerializers::SerializableResource.new(TestObject.new(foo: 'bar'), serializer: serializer_class, adapter: described_class).as_json }
|
||||
|
||||
let(:serializer_class) {}
|
||||
|
||||
context 'when serializer defines no context' do
|
||||
let(:serializer_class) { TestWithBasicContextSerializer }
|
||||
|
||||
|
@@ -1,14 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Dereferencer do
|
||||
describe '#object' do
|
||||
subject { described_class.new(uri, permitted_origin: permitted_origin, signature_actor: signature_actor).object }
|
||||
|
||||
let(:object) { { '@context': 'https://www.w3.org/ns/activitystreams', id: 'https://example.com/foo', type: 'Note', content: 'Hoge' } }
|
||||
let(:permitted_origin) { 'https://example.com' }
|
||||
let(:signature_actor) { nil }
|
||||
let(:uri) { nil }
|
||||
|
||||
subject { described_class.new(uri, permitted_origin: permitted_origin, signature_actor: signature_actor).object }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/foo').to_return(body: Oj.dump(object), headers: { 'Content-Type' => 'application/activity+json' })
|
||||
end
|
||||
|
@@ -1,8 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::LinkedDataSignature do
|
||||
include JsonLdHelper
|
||||
|
||||
subject { described_class.new(json) }
|
||||
|
||||
let!(:sender) { Fabricate(:account, uri: 'http://example.com/alice') }
|
||||
|
||||
let(:raw_json) do
|
||||
@@ -14,8 +18,6 @@ RSpec.describe ActivityPub::LinkedDataSignature do
|
||||
|
||||
let(:json) { raw_json.merge('signature' => signature) }
|
||||
|
||||
subject { described_class.new(json) }
|
||||
|
||||
before do
|
||||
stub_jsonld_contexts!
|
||||
end
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::TagManager do
|
||||
|
Reference in New Issue
Block a user