invite_spec.rb 734 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe 'invites' do
  4. let(:invite) { Fabricate(:invite) }
  5. context 'when requesting a JSON document' do
  6. it 'returns a JSON document with expected attributes' do
  7. get "/invite/#{invite.code}", headers: { 'Accept' => 'application/activity+json' }
  8. expect(response).to have_http_status(200)
  9. expect(response.media_type).to eq 'application/json'
  10. expect(body_as_json[:invite_code]).to eq invite.code
  11. end
  12. end
  13. context 'when not requesting a JSON document' do
  14. it 'returns an HTML page' do
  15. get "/invite/#{invite.code}"
  16. expect(response).to have_http_status(200)
  17. expect(response.media_type).to eq 'text/html'
  18. end
  19. end
  20. end