You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.8 KiB

  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 'on a toot with long text' do
  13. let(:text) { "This toot's text is longer than the allowed number of characters" }
  14. it 'truncates toot text appropriately' do
  15. expect(subject).to eq "#{account.acct}: “This toot's text is longer tha…”"
  16. end
  17. end
  18. context 'on a toot with long text with a newline' do
  19. let(:text) { "This toot's text is longer\nthan 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…”"
  22. end
  23. end
  24. context 'on a toot with a content warning' do
  25. let(:spoiler) { 'long toot' }
  26. it 'displays spoiler text instead of toot content' do
  27. expect(subject).to eq "#{account.acct}: CW “long toot”"
  28. end
  29. end
  30. context 'on a toot with sensitive media' do
  31. let(:sensitive) { true }
  32. it 'displays that the media is sensitive' do
  33. expect(subject).to eq "#{account.acct}: “This is a toot” (sensitive)"
  34. end
  35. end
  36. context 'on a reblog' do
  37. let(:reblog) { Fabricate(:status, text: 'This is a toot') }
  38. it 'display that the toot is a reblog' do
  39. expect(subject).to eq "#{account.acct} boosted #{reblog.account.acct}: “This is a toot”"
  40. end
  41. end
  42. end
  43. end