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.

33 lines
1.0 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe 'Link headers' do
  4. describe 'on the account show page' do
  5. let(:account) { Fabricate(:account, username: 'test') }
  6. before do
  7. get short_account_path(username: account)
  8. end
  9. it 'contains webfinger url in link header' do
  10. link_header = link_header_with_type('application/jrd+json')
  11. expect(link_header.href).to match 'http://www.example.com/.well-known/webfinger?resource=acct%3Atest%40cb6e6126.ngrok.io'
  12. expect(link_header.attr_pairs.first).to eq %w(rel lrdd)
  13. end
  14. it 'contains activitypub url in link header' do
  15. link_header = link_header_with_type('application/activity+json')
  16. expect(link_header.href).to eq 'https://cb6e6126.ngrok.io/users/test'
  17. expect(link_header.attr_pairs.first).to eq %w(rel alternate)
  18. end
  19. def link_header_with_type(type)
  20. LinkHeader.parse(response.headers['Link'].to_s).links.find do |link|
  21. link.attr_pairs.any? { |pair| pair == ['type', type] }
  22. end
  23. end
  24. end
  25. end