1
0

account_show_page_spec.rb 917 B

123456789101112131415161718192021222324252627282930313233
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'The account show page' do
  4. it 'has valid opengraph tags' do
  5. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  6. _status = Fabricate(:status, account: alice, text: 'Hello World')
  7. get '/@alice'
  8. expect(head_link_icons.size).to eq(3) # Three favicons with sizes
  9. expect(head_meta_content('og:title')).to match alice.display_name
  10. expect(head_meta_content('og:type')).to eq 'profile'
  11. expect(head_meta_content('og:image')).to match '.+'
  12. expect(head_meta_content('og:url')).to eq short_account_url(username: alice.username)
  13. end
  14. def head_link_icons
  15. response
  16. .parsed_body
  17. .search('html head link[rel=icon]')
  18. end
  19. def head_meta_content(property)
  20. response
  21. .parsed_body
  22. .search("html head meta[property='#{property}']")
  23. .attr('content')
  24. .text
  25. end
  26. end