show.html.haml_spec.rb 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. allow(view).to receive(:single_user_mode?).and_return(false)
  14. assign(:instance_presenter, InstancePresenter.new)
  15. end
  16. it 'has valid opengraph tags' do
  17. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  18. status = Fabricate(:status, account: alice, text: 'Hello World')
  19. media = Fabricate(:media_attachment, account: alice, status: status, type: :video)
  20. assign(:status, status)
  21. assign(:account, alice)
  22. assign(:descendant_threads, [])
  23. render
  24. header_tags = view.content_for(:header_tags)
  25. expect(header_tags).to match(%r{<meta content=".+" property="og:title" />})
  26. expect(header_tags).to match(%r{<meta content="article" property="og:type" />})
  27. expect(header_tags).to match(%r{<meta content=".+" property="og:image" />})
  28. expect(header_tags).to match(%r{<meta content="http://.+" property="og:url" />})
  29. end
  30. it 'has twitter player tag' do
  31. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  32. status = Fabricate(:status, account: alice, text: 'Hello World')
  33. media = Fabricate(:media_attachment, account: alice, status: status, type: :video)
  34. assign(:status, status)
  35. assign(:account, alice)
  36. assign(:descendant_threads, [])
  37. render
  38. header_tags = view.content_for(:header_tags)
  39. expect(header_tags).to match(%r{<meta content="http://.+/media/.+/player" property="twitter:player" />})
  40. expect(header_tags).to match(%r{<meta content="player" property="twitter:card" />})
  41. end
  42. end