mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00

Some checks failed
Bundler Audit / security (push) Has been cancelled
Check i18n / check-i18n (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (ruby) (push) Has been cancelled
Check formatting / lint (push) Has been cancelled
Haml Linting / lint (push) Has been cancelled
Ruby Linting / lint (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
Ruby Testing / build (production) (push) Has been cancelled
Ruby Testing / build (test) (push) Has been cancelled
Ruby Testing / test (.ruby-version) (push) Has been cancelled
Ruby Testing / test (3.2) (push) Has been cancelled
Ruby Testing / test (3.3) (push) Has been cancelled
Ruby Testing / ImageMagick tests (.ruby-version) (push) Has been cancelled
Ruby Testing / ImageMagick tests (3.2) (push) Has been cancelled
Ruby Testing / ImageMagick tests (3.3) (push) Has been cancelled
Ruby Testing / End to End testing (.ruby-version) (push) Has been cancelled
Ruby Testing / End to End testing (3.2) (push) Has been cancelled
Ruby Testing / End to End testing (3.3) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
60 lines
2.4 KiB
Ruby
60 lines
2.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe ActivityPub::NoteSerializer do
|
|
subject { serialized_record_json(parent, described_class, adapter: ActivityPub::Adapter) }
|
|
|
|
let!(:account) { Fabricate(:account) }
|
|
let!(:other) { Fabricate(:account) }
|
|
let!(:parent) { Fabricate(:status, account: account, visibility: :public, language: 'zh-TW') }
|
|
let!(:reply_by_account_first) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
|
|
let!(:reply_by_account_next) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
|
|
let!(:reply_by_other_first) { Fabricate(:status, account: other, thread: parent, visibility: :public) }
|
|
let!(:reply_by_account_third) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
|
|
let!(:reply_by_account_visibility_direct) { Fabricate(:status, account: account, thread: parent, visibility: :direct) }
|
|
|
|
it 'has the expected shape and replies collection' do
|
|
expect(subject).to include({
|
|
'@context' => include('https://www.w3.org/ns/activitystreams'),
|
|
'type' => 'Note',
|
|
'attributedTo' => ActivityPub::TagManager.instance.uri_for(account),
|
|
'contentMap' => include({
|
|
'zh-TW' => a_kind_of(String),
|
|
}),
|
|
'replies' => replies_collection_values,
|
|
})
|
|
end
|
|
|
|
def replies_collection_values
|
|
include(
|
|
'type' => eql('Collection'),
|
|
'first' => include(
|
|
'type' => eql('CollectionPage'),
|
|
'items' => reply_items
|
|
)
|
|
)
|
|
end
|
|
|
|
def reply_items
|
|
include(reply_by_account_first.uri, reply_by_account_next.uri, reply_by_account_third.uri) # Public self replies
|
|
.and(not_include(reply_by_other_first.uri)) # Replies from others
|
|
.and(not_include(reply_by_account_visibility_direct.uri)) # Replies with direct visibility
|
|
end
|
|
|
|
context 'with a quote' do
|
|
let(:quoted_status) { Fabricate(:status) }
|
|
let!(:quote) { Fabricate(:quote, status: parent, quoted_status: quoted_status, state: :accepted) }
|
|
|
|
it 'has the expected shape' do
|
|
expect(subject).to include({
|
|
'type' => 'Note',
|
|
'quote' => ActivityPub::TagManager.instance.uri_for(quote.quoted_status),
|
|
'quoteUri' => ActivityPub::TagManager.instance.uri_for(quote.quoted_status),
|
|
'_misskey_quote' => ActivityPub::TagManager.instance.uri_for(quote.quoted_status),
|
|
'quoteAuthorization' => ActivityPub::TagManager.instance.approval_uri_for(quote),
|
|
})
|
|
end
|
|
end
|
|
end
|