2023-11-13 14:27:00 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 07:12:25 +02:00
|
|
|
RSpec.describe 'invites' do
|
2023-11-13 14:27:00 +01:00
|
|
|
let(:invite) { Fabricate(:invite) }
|
|
|
|
|
|
|
|
context 'when requesting a JSON document' do
|
|
|
|
it 'returns a JSON document with expected attributes' do
|
|
|
|
get "/invite/#{invite.code}", headers: { 'Accept' => 'application/activity+json' }
|
|
|
|
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(response.media_type).to eq 'application/json'
|
|
|
|
|
2024-09-06 11:58:46 +02:00
|
|
|
expect(response.parsed_body[:invite_code]).to eq invite.code
|
2023-11-13 14:27:00 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when not requesting a JSON document' do
|
|
|
|
it 'returns an HTML page' do
|
|
|
|
get "/invite/#{invite.code}"
|
|
|
|
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(response.media_type).to eq 'text/html'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|