show.html.haml_spec.rb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe 'statuses/show.html.haml', :without_verify_partial_doubles do
  4. let(:alice) { Fabricate(:account, username: 'alice', display_name: 'Alice') }
  5. let(:status) { Fabricate(:status, account: alice, text: 'Hello World') }
  6. before do
  7. allow(view).to receive_messages(api_oembed_url: '', site_title: 'example site', site_hostname: 'example.com', full_asset_url: '//asset.host/image.svg', current_account: nil, single_user_mode?: false)
  8. allow(view).to receive(:local_time)
  9. allow(view).to receive(:local_time_ago)
  10. assign(:instance_presenter, InstancePresenter.new)
  11. Fabricate(:media_attachment, account: alice, status: status, type: :video)
  12. assign(:status, status)
  13. assign(:account, alice)
  14. assign(:descendant_threads, [])
  15. end
  16. it 'has valid opengraph tags' do
  17. render
  18. expect(header_tags)
  19. .to match(/<meta content=".+" property="og:title">/)
  20. .and match(/<meta content="article" property="og:type">/)
  21. .and match(/<meta content=".+" property="og:image">/)
  22. .and match(%r{<meta content="http://.+" property="og:url">})
  23. end
  24. it 'has twitter player tag' do
  25. render
  26. expect(header_tags)
  27. .to match(%r{<meta content="http://.+/media/.+/player" property="twitter:player">})
  28. .and match(/<meta content="player" property="twitter:card">/)
  29. end
  30. def header_tags
  31. view.content_for(:header_tags)
  32. end
  33. end