Skip to content

Commit

Permalink
Add v0.9 compatibility adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
pravi committed Sep 22, 2020
1 parent a1aa5a2 commit f725a63
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/serializers/export/aspect_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Export
class AspectSerializer < ActiveModel::Serializer
class AspectSerializer < AMS::V09::Serializer
attributes :name
end
end
2 changes: 1 addition & 1 deletion app/serializers/export/contact_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Export
class ContactSerializer < ActiveModel::Serializer
class ContactSerializer < AMS::V09::Serializer
attributes :sharing,
:receiving,
:following,
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/export/others_data_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Export
class OthersDataSerializer < ActiveModel::Serializer
class OthersDataSerializer < AMS::V09::Serializer
# Relayables of other people in the archive: comments, likes, participations, poll participations where author is
# the archive owner
has_many :relayables, serializer: FlatMapArraySerializer, each_serializer: FederationEntitySerializer
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/export/user_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Export
class UserSerializer < ActiveModel::Serializer
class UserSerializer < AMS::V09::Serializer
attributes :username,
:email,
:language,
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/federation_entity_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This is an ActiveModel::Serializer based class which uses DiasporaFederation::Entity JSON serialization
# features in order to serialize local DB objects. To determine a type of entity class to use the same routines
# are used as for federation messages generation.
class FederationEntitySerializer < ActiveModel::Serializer
class FederationEntitySerializer < AMS::V09::Serializer
include SerializerPostProcessing

private
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/flat_map_array_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class FlatMapArraySerializer < ActiveModel::ArraySerializer
class FlatMapArraySerializer < ActiveModelSerializers::SerializableResource
def serializable_object(options={})
@object.flat_map do |subarray|
subarray.map do |item|
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/notification_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class NotificationSerializer < ActiveModel::Serializer
class NotificationSerializer < AMS::V09::Serializer
attributes :id,
:target_type,
:target_id,
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/user_info_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class UserInfoSerializer < ActiveModel::Serializer
class UserInfoSerializer < AMS::V09::Serializer
attributes :sub, :name, :nickname, :profile, :picture

def sub
Expand Down
6 changes: 3 additions & 3 deletions spec/serializers/serializer_post_processing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

describe SerializerPostProcessing do
describe "#modify_serializable_object" do
it "allows to modify serializable object of ActiveModel::Serializer ancestor" do
class TestSerializer < ActiveModel::Serializer
it "allows to modify serializable object of AMS::V09::Serializer ancestor" do
class TestSerializer < AMS::V09::Serializer
include SerializerPostProcessing

def modify_serializable_object(*)
Expand All @@ -21,7 +21,7 @@ def modify_serializable_object(*)

describe "#except" do
it "allows to except a key from attributes" do
class TestSerializer2 < ActiveModel::Serializer
class TestSerializer2 < AMS::V09::Serializer
include SerializerPostProcessing

attributes :key_to_exclude
Expand Down
4 changes: 2 additions & 2 deletions spec/support/serializer_matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def serializer_class
def pick_serializer_class
return association_serializer_class unless association_serializer_class.nil?
return @serializer_from_options unless @serializer_from_options.nil?
return ActiveModel::ArraySerializer unless each_serializer_class.nil?
return ActiveModelSerializers::SerializableResource unless each_serializer_class.nil?
end
end

Expand All @@ -82,6 +82,6 @@ def pick_serializer_class
# NOTE: this matcher uses knowledge of AMS internals
RSpec::Matchers.define :serialize_each_with do |expected|
match do |actual|
actual.is_a?(ActiveModel::ArraySerializer) && actual.instance_variable_get("@each_serializer") == expected
actual.is_a?(ActiveModelSerializers::SerializableResource) && actual.instance_variable_get("@each_serializer") == expected
end
end

0 comments on commit f725a63

Please sign in to comment.