embed_spec.rb 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'Status embed' do
  4. describe 'GET /users/:account_username/statuses/:id/embed' do
  5. subject { get "/users/#{account.username}/statuses/#{status.id}/embed" }
  6. let(:account) { Fabricate(:account) }
  7. let(:status) { Fabricate(:status, account: account) }
  8. context 'when account is suspended' do
  9. let(:account) { Fabricate(:account, suspended: true) }
  10. it 'returns http gone' do
  11. subject
  12. expect(response)
  13. .to have_http_status(410)
  14. end
  15. end
  16. context 'when status is a reblog' do
  17. let(:original_account) { Fabricate(:account, domain: 'example.com') }
  18. let(:original_status) { Fabricate(:status, account: original_account, url: 'https://example.com/123') }
  19. let(:status) { Fabricate(:status, account: account, reblog: original_status) }
  20. it 'returns http not found' do
  21. subject
  22. expect(response)
  23. .to have_http_status(404)
  24. end
  25. end
  26. context 'when status is public' do
  27. it 'renders status successfully', :aggregate_failures do
  28. subject
  29. expect(response)
  30. .to have_http_status(200)
  31. expect(response.parsed_body.at('body.embed'))
  32. .to be_present
  33. expect(response.headers).to include(
  34. 'Vary' => 'Accept, Accept-Language, Cookie',
  35. 'Cache-Control' => include('public'),
  36. 'Link' => include('activity+json')
  37. )
  38. end
  39. end
  40. context 'when status is private' do
  41. let(:status) { Fabricate(:status, account: account, visibility: :private) }
  42. it 'returns http not found' do
  43. subject
  44. expect(response)
  45. .to have_http_status(404)
  46. end
  47. end
  48. context 'when status is direct' do
  49. let(:status) { Fabricate(:status, account: account, visibility: :direct) }
  50. it 'returns http not found' do
  51. subject
  52. expect(response)
  53. .to have_http_status(404)
  54. end
  55. end
  56. end
  57. end