# frozen_string_literal: true require 'spec_helper' describe G5Updatable::LocationsController, type: :controller do routes { G5Updatable::Engine.routes } let!(:location) { create(:location) } describe 'GET show' do subject(:show) { safe_get :show, params } context 'valid request' do let(:params) { { urn: location.urn } } let(:json) { JSON.parse(response.body)['location'] } it { is_expected.to be_successful } it 'returns the correct location' do show expect(json['uid']).to eq(location.uid) end end context 'invalid location' do let(:params) { { urn: 'bogus' } } # I don't know whether this behavior was originally intended, # but it's been that way in production since forever, so that's # what we'll support for the sake of backwards compatibility it { is_expected.to be_successful } it 'returns an empty response' do expect(response.body).to be_empty end end end end