1
0

serializer_spec.rb 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe RSS::Serializer do
  4. describe '#status_title' do
  5. let(:text) { 'This is a toot' }
  6. let(:spoiler) { '' }
  7. let(:sensitive) { false }
  8. let(:reblog) { nil }
  9. let(:account) { Fabricate(:account) }
  10. let(:status) { Fabricate(:status, account: account, text: text, spoiler_text: spoiler, sensitive: sensitive, reblog: reblog) }
  11. subject { RSS::Serializer.new.send(:status_title, status) }
  12. context 'if destroyed?' do
  13. it 'returns "#{account.acct} deleted status"' do
  14. status.destroy!
  15. expect(subject).to eq "#{account.acct} deleted status"
  16. end
  17. end
  18. context 'on a toot with long text' do
  19. let(:text) { "This toot's text is longer than the allowed number of characters" }
  20. it 'truncates toot text appropriately' do
  21. expect(subject).to eq "#{account.acct}: “This toot's text is longer tha…”"
  22. end
  23. end
  24. context 'on a toot with long text with a newline' do
  25. let(:text) { "This toot's text is longer\nthan the allowed number of characters" }
  26. it 'truncates toot text appropriately' do
  27. expect(subject).to eq "#{account.acct}: “This toot's text is longer…”"
  28. end
  29. end
  30. context 'on a toot with a content warning' do
  31. let(:spoiler) { 'long toot' }
  32. it 'displays spoiler text instead of toot content' do
  33. expect(subject).to eq "#{account.acct}: CW “long toot”"
  34. end
  35. end
  36. context 'on a toot with sensitive media' do
  37. let(:sensitive) { true }
  38. it 'displays that the media is sensitive' do
  39. expect(subject).to eq "#{account.acct}: “This is a toot” (sensitive)"
  40. end
  41. end
  42. context 'on a reblog' do
  43. let(:reblog) { Fabricate(:status, text: 'This is a toot') }
  44. it 'display that the toot is a reblog' do
  45. expect(subject).to eq "#{account.acct} boosted #{reblog.account.acct}: “This is a toot”"
  46. end
  47. end
  48. end
  49. end