Sha256: 46a7bc209cbc5c979680080e2fc99e2bca0384d3d9878337eaf6adfae0a77555
Contents?: true
Size: 1.43 KB
Versions: 6
Compression:
Stored size: 1.43 KB
Contents
require 'cgi' require 'uri' describe 'Serializer options', type: :request do it 'adds meta with pagination information' do get '/api/v1/locations', params: {}, headers: default_headers expect(response).to have_http_status(:ok) expect(json_response).to have_key('meta') expect(json_response['meta'].keys).to include( 'current_page', 'total_pages', 'total_count', 'padding', 'page_size', 'max_page_size' ) end it 'adds links' do get '/api/v1/locations', params: {}, headers: default_headers expect(response).to have_http_status(:ok) expect(json_response).to have_key('links') expect(json_response['links'].keys).to include('self', 'first', 'last') end it 'adds client requested fields information to links' do q = { fields: { locations: 'latitude' } } get "/api/v1/locations?#{q.to_query}", params: {}, headers: default_headers expect(response).to have_http_status(:ok) expect(query_params(json_response.dig('links', 'self'))) .to include('fields[locations]' => ['latitude']) end it 'adds client requested include information to links' do q = { include: 'labels' } get "/api/v1/locations?#{q.to_query}", params: {}, headers: default_headers expect(response).to have_http_status(:ok) expect(query_params(json_response.dig('links', 'self'))) .to include('include' => ['labels']) end private def query_params(link) CGI.parse(URI(link).query) end end
Version data entries
6 entries across 6 versions & 1 rubygems