闭社主体 forked from https://github.com/tootsuite/mastodon
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.

81 lines
3.2 KiB

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