show.html.haml_spec.rb 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. allow(view).to receive_messages(api_oembed_url: '', show_landing_strip?: true, site_title: 'example site', site_hostname: 'example.com', full_asset_url: '//asset.host/image.svg', current_account: nil, single_user_mode?: false)
  6. allow(view).to receive(:local_time)
  7. allow(view).to receive(:local_time_ago)
  8. assign(:instance_presenter, InstancePresenter.new)
  9. end
  10. it 'has valid opengraph tags' do
  11. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  12. status = Fabricate(:status, account: alice, text: 'Hello World')
  13. Fabricate(:media_attachment, account: alice, status: status, type: :video)
  14. assign(:status, status)
  15. assign(:account, alice)
  16. assign(:descendant_threads, [])
  17. render
  18. header_tags = view.content_for(:header_tags)
  19. expect(header_tags).to match(/<meta content=".+" property="og:title">/)
  20. expect(header_tags).to match(/<meta content="article" property="og:type">/)
  21. expect(header_tags).to match(/<meta content=".+" property="og:image">/)
  22. expect(header_tags).to match(%r{<meta content="http://.+" property="og:url">})
  23. end
  24. it 'has twitter player tag' do
  25. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  26. status = Fabricate(:status, account: alice, text: 'Hello World')
  27. Fabricate(:media_attachment, account: alice, status: status, type: :video)
  28. assign(:status, status)
  29. assign(:account, alice)
  30. assign(:descendant_threads, [])
  31. render
  32. header_tags = view.content_for(:header_tags)
  33. expect(header_tags).to match(%r{<meta content="http://.+/media/.+/player" property="twitter:player">})
  34. expect(header_tags).to match(/<meta content="player" property="twitter:card">/)
  35. end
  36. end