logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

show.html.haml_spec.rb (3543B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe 'stream_entries/show.html.haml', without_verify_partial_doubles: true do
  4. before do
  5. double(:api_oembed_url => '')
  6. double(:account_stream_entry_url => '')
  7. allow(view).to receive(:show_landing_strip?).and_return(true)
  8. allow(view).to receive(:site_title).and_return('example site')
  9. allow(view).to receive(:site_hostname).and_return('example.com')
  10. allow(view).to receive(:full_asset_url).and_return('//asset.host/image.svg')
  11. allow(view).to receive(:local_time)
  12. allow(view).to receive(:local_time_ago)
  13. end
  14. it 'has valid author h-card and basic data for a detailed_status' do
  15. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  16. bob = Fabricate(:account, username: 'bob', display_name: 'Bob')
  17. status = Fabricate(:status, account: alice, text: 'Hello World')
  18. reply = Fabricate(:status, account: bob, thread: status, text: 'Hello Alice')
  19. assign(:status, status)
  20. assign(:stream_entry, status.stream_entry)
  21. assign(:account, alice)
  22. assign(:type, status.stream_entry.activity_type.downcase)
  23. render
  24. mf2 = Microformats.parse(rendered)
  25. expect(mf2.entry.name.to_s).to eq status.text
  26. expect(mf2.entry.url.to_s).not_to be_empty
  27. expect(mf2.entry.author.name.to_s).to eq alice.display_name
  28. expect(mf2.entry.author.url.to_s).not_to be_empty
  29. end
  30. it 'has valid h-cites for p-in-reply-to and p-comment' do
  31. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  32. bob = Fabricate(:account, username: 'bob', display_name: 'Bob')
  33. carl = Fabricate(:account, username: 'carl', display_name: 'Carl')
  34. status = Fabricate(:status, account: alice, text: 'Hello World')
  35. reply = Fabricate(:status, account: bob, thread: status, text: 'Hello Alice')
  36. comment = Fabricate(:status, account: carl, thread: reply, text: 'Hello Bob')
  37. assign(:status, reply)
  38. assign(:stream_entry, reply.stream_entry)
  39. assign(:account, alice)
  40. assign(:type, reply.stream_entry.activity_type.downcase)
  41. assign(:ancestors, reply.stream_entry.activity.ancestors(1, bob) )
  42. assign(:descendants, reply.stream_entry.activity.descendants(bob))
  43. render
  44. mf2 = Microformats.parse(rendered)
  45. expect(mf2.entry.name.to_s).to eq reply.text
  46. expect(mf2.entry.url.to_s).not_to be_empty
  47. expect(mf2.entry.comment.url.to_s).not_to be_empty
  48. expect(mf2.entry.comment.author.name.to_s).to eq carl.display_name
  49. expect(mf2.entry.comment.author.url.to_s).not_to be_empty
  50. expect(mf2.entry.in_reply_to.url.to_s).not_to be_empty
  51. expect(mf2.entry.in_reply_to.author.name.to_s).to eq alice.display_name
  52. expect(mf2.entry.in_reply_to.author.url.to_s).not_to be_empty
  53. end
  54. it 'has valid opengraph tags' do
  55. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  56. status = Fabricate(:status, account: alice, text: 'Hello World')
  57. assign(:status, status)
  58. assign(:stream_entry, status.stream_entry)
  59. assign(:account, alice)
  60. assign(:type, status.stream_entry.activity_type.downcase)
  61. render
  62. header_tags = view.content_for(:header_tags)
  63. expect(header_tags).to match(%r{<meta content=".+" property="og:title" />})
  64. expect(header_tags).to match(%r{<meta content="article" property="og:type" />})
  65. expect(header_tags).to match(%r{<meta content=".+" property="og:image" />})
  66. expect(header_tags).to match(%r{<meta content="http://.+" property="og:url" />})
  67. end
  68. end