1
0

oembed_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'API OEmbed' do
  4. describe 'GET /api/oembed' do
  5. before { host! Rails.configuration.x.local_domain }
  6. context 'when status is public' do
  7. let(:status) { Fabricate(:status, visibility: :public) }
  8. it 'returns success with private cache control headers' do
  9. get '/api/oembed', params: { url: short_account_status_url(status.account, status) }
  10. expect(response)
  11. .to have_http_status(200)
  12. expect(response.content_type)
  13. .to start_with('application/json')
  14. expect(response.headers['Cache-Control'])
  15. .to include('private, no-store')
  16. end
  17. end
  18. context 'when status is not public' do
  19. let(:status) { Fabricate(:status, visibility: :direct) }
  20. it 'returns not found' do
  21. get '/api/oembed', params: { url: short_account_status_url(status.account, status) }
  22. expect(response)
  23. .to have_http_status(404)
  24. expect(response.content_type)
  25. .to start_with('application/json')
  26. end
  27. end
  28. end
  29. end