collection_serializer_spec.rb 951 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe ActivityPub::CollectionSerializer do
  4. describe '.serializer_for' do
  5. subject { described_class.serializer_for(model, {}) }
  6. context 'with a Status model' do
  7. let(:model) { Status.new }
  8. it { is_expected.to eq(ActivityPub::NoteSerializer) }
  9. end
  10. context 'with a FeaturedTag model' do
  11. let(:model) { FeaturedTag.new }
  12. it { is_expected.to eq(ActivityPub::HashtagSerializer) }
  13. end
  14. context 'with an ActivityPub::CollectionPresenter' do
  15. let(:model) { ActivityPub::CollectionPresenter.new }
  16. it { is_expected.to eq(described_class) }
  17. end
  18. context 'with a String' do
  19. let(:model) { '' }
  20. it { is_expected.to eq(described_class::StringSerializer) }
  21. end
  22. context 'with an Array' do
  23. let(:model) { [] }
  24. it { is_expected.to eq(ActiveModel::Serializer::CollectionSerializer) }
  25. end
  26. end
  27. end