mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
41 lines
1.3 KiB
Ruby
41 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe 'Api::V1::Countries::Borders', type: :request do
|
|
describe 'GET /index' do
|
|
let(:user) { create(:user) }
|
|
|
|
context 'when user is not authenticated' do
|
|
it 'returns http unauthorized' do
|
|
get '/api/v1/countries/borders'
|
|
|
|
expect(response).to have_http_status(:unauthorized)
|
|
end
|
|
|
|
it 'returns X-Dawarich-Response header' do
|
|
get '/api/v1/countries/borders'
|
|
|
|
expect(response.headers['X-Dawarich-Response']).to eq('Hey, I\'m alive!')
|
|
expect(response.headers['X-Dawarich-Version']).to eq(APP_VERSION)
|
|
end
|
|
end
|
|
|
|
context 'when user is authenticated' do
|
|
it 'returns a list of countries with borders' do
|
|
get '/api/v1/countries/borders', headers: { 'Authorization' => "Bearer #{user.api_key}" }
|
|
|
|
expect(response).to have_http_status(:success)
|
|
expect(response.body).to include('AF')
|
|
expect(response.body).to include('ZW')
|
|
end
|
|
|
|
it 'returns X-Dawarich-Response header' do
|
|
get '/api/v1/countries/borders', headers: { 'Authorization' => "Bearer #{user.api_key}" }
|
|
|
|
expect(response.headers['X-Dawarich-Response']).to eq('Hey, I\'m alive and authenticated!')
|
|
expect(response.headers['X-Dawarich-Version']).to eq(APP_VERSION)
|
|
end
|
|
end
|
|
end
|
|
end
|