闭社主体 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.

83 lines
3.2 KiB

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