|
|
|
@ -3,43 +3,51 @@
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
|
|
RSpec.describe ActivityPub::Adapter do
|
|
|
|
|
class TestObject < ActiveModelSerializers::Model
|
|
|
|
|
attributes :foo
|
|
|
|
|
end
|
|
|
|
|
before do
|
|
|
|
|
test_object_class = Class.new(ActiveModelSerializers::Model) do
|
|
|
|
|
attributes :foo
|
|
|
|
|
end
|
|
|
|
|
stub_const('TestObject', test_object_class)
|
|
|
|
|
|
|
|
|
|
class TestWithBasicContextSerializer < ActivityPub::Serializer
|
|
|
|
|
attributes :foo
|
|
|
|
|
end
|
|
|
|
|
test_with_basic_context_serializer = Class.new(ActivityPub::Serializer) do
|
|
|
|
|
attributes :foo
|
|
|
|
|
end
|
|
|
|
|
stub_const('TestWithBasicContextSerializer', test_with_basic_context_serializer)
|
|
|
|
|
|
|
|
|
|
class TestWithNamedContextSerializer < ActivityPub::Serializer
|
|
|
|
|
context :security
|
|
|
|
|
attributes :foo
|
|
|
|
|
end
|
|
|
|
|
test_with_named_context_serializer = Class.new(ActivityPub::Serializer) do
|
|
|
|
|
context :security
|
|
|
|
|
attributes :foo
|
|
|
|
|
end
|
|
|
|
|
stub_const('TestWithNamedContextSerializer', test_with_named_context_serializer)
|
|
|
|
|
|
|
|
|
|
class TestWithNestedNamedContextSerializer < ActivityPub::Serializer
|
|
|
|
|
attributes :foo
|
|
|
|
|
test_with_nested_named_context_serializer = Class.new(ActivityPub::Serializer) do
|
|
|
|
|
attributes :foo
|
|
|
|
|
|
|
|
|
|
has_one :virtual_object, key: :baz, serializer: TestWithNamedContextSerializer
|
|
|
|
|
has_one :virtual_object, key: :baz, serializer: TestWithNamedContextSerializer
|
|
|
|
|
|
|
|
|
|
def virtual_object
|
|
|
|
|
object
|
|
|
|
|
def virtual_object
|
|
|
|
|
object
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
stub_const('TestWithNestedNamedContextSerializer', test_with_nested_named_context_serializer)
|
|
|
|
|
|
|
|
|
|
class TestWithContextExtensionSerializer < ActivityPub::Serializer
|
|
|
|
|
context_extensions :sensitive
|
|
|
|
|
attributes :foo
|
|
|
|
|
end
|
|
|
|
|
test_with_context_extension_serializer = Class.new(ActivityPub::Serializer) do
|
|
|
|
|
context_extensions :sensitive
|
|
|
|
|
attributes :foo
|
|
|
|
|
end
|
|
|
|
|
stub_const('TestWithContextExtensionSerializer', test_with_context_extension_serializer)
|
|
|
|
|
|
|
|
|
|
class TestWithNestedContextExtensionSerializer < ActivityPub::Serializer
|
|
|
|
|
context_extensions :manually_approves_followers
|
|
|
|
|
attributes :foo
|
|
|
|
|
test_with_nested_context_extension_serializer = Class.new(ActivityPub::Serializer) do
|
|
|
|
|
context_extensions :manually_approves_followers
|
|
|
|
|
attributes :foo
|
|
|
|
|
|
|
|
|
|
has_one :virtual_object, key: :baz, serializer: TestWithContextExtensionSerializer
|
|
|
|
|
has_one :virtual_object, key: :baz, serializer: TestWithContextExtensionSerializer
|
|
|
|
|
|
|
|
|
|
def virtual_object
|
|
|
|
|
object
|
|
|
|
|
def virtual_object
|
|
|
|
|
object
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
stub_const('TestWithNestedContextExtensionSerializer', test_with_nested_context_extension_serializer)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe '#serializable_hash' do
|
|
|
|
|