diaspora/spec/serializers/export/user_serializer_spec.rb
Benjamin Neff 763dffa328
Always strip exif data and drop user setting for it
Some imagemagick-versions (I tested Ubuntu 22.04 and debian bullseye)
always loose exif data when converting from jpg to webp. So this made
our CI fail now, but even if it wasn't failing before, some pods always
had and have versions which might loose the information anyway. So
having a setting to keep exif information is kinda pointless, if we
can't guarantee that the information isn't lost. Also, diaspora isn't a
photo sharing platform and we don't display exif information anywhere,
so I think we should just always strip exif data (which was already the
default before), as we don't need them.
2023-06-04 04:25:01 +02:00

81 lines
3.2 KiB
Ruby

# frozen_string_literal: true
describe Export::UserSerializer do
let(:user) { FactoryBot.create(:user) }
let(:serializer) { Export::UserSerializer.new(user.id, root: false) }
it "has basic user's attributes" do
expect(serializer.attributes).to eq(
username: user.username,
email: user.email,
language: user.language,
private_key: user.serialized_private_key,
disable_mail: user.disable_mail,
show_community_spotlight_in_stream: user.show_community_spotlight_in_stream,
auto_follow_back: user.auto_follow_back,
auto_follow_back_aspect: user.auto_follow_back_aspect,
blocks: user.blocks
)
end
it "uses FederationEntitySerializer to serialize user profile" do
expect(Export::UserSerializer).to serialize_association(:profile)
.with_serializer(FederationEntitySerializer)
.with_object(user.profile)
serializer.associations
end
it "uses AspectSerializer for array serializing contact_groups" do
DataGenerator.create(user, %i[first_aspect work_aspect])
expect(Export::UserSerializer).to serialize_association(:contact_groups)
.with_each_serializer(Export::AspectSerializer)
.with_objects([user.aspects.first, user.aspects.second])
serializer.associations
end
it "uses ContactSerializer for array serializing contacts" do
DataGenerator.create(user, %i[mutual_friend mutual_friend])
expect(Export::UserSerializer).to serialize_association(:contacts)
.with_each_serializer(Export::ContactSerializer)
.with_objects([user.contacts.first, user.contacts.second])
serializer.associations
end
it "uses OwnPostSerializer for array serializing posts" do
DataGenerator.create(user, %i[public_status_message private_status_message])
expect(Export::UserSerializer).to serialize_association(:posts)
.with_each_serializer(Export::OwnPostSerializer)
.with_objects([user.posts.first, user.posts.second])
serializer.associations
end
it "serializes followed tags" do
DataGenerator.create(user, %i[tag_following tag_following])
expect(Export::UserSerializer).to serialize_association(:followed_tags)
.with_objects([user.followed_tags.first.name, user.followed_tags.second.name])
serializer.associations
end
it "uses OwnRelayablesSerializer for array serializing relayables" do
DataGenerator.create(user, :activity)
objects = %i[comments likes poll_participations].map do |association|
user.person.send(association).first
end
expect(Export::UserSerializer).to serialize_association(:relayables)
.with_each_serializer(Export::OwnRelayablesSerializer)
.with_objects(objects)
serializer.associations
end
it "serializes post subscriptions" do
DataGenerator.create(user, %i[participation participation])
subscriptions = user.person.participations.map do |participation|
participation.target.guid
end
expect(Export::UserSerializer).to serialize_association(:post_subscriptions)
.with_objects(subscriptions)
serializer.associations
end
end