require_relative '../test_config' require 'helix_versioning_engine' require 'tempfile' describe 'Config services' do include Rack::Test::Methods def app HELIX_WEB_SERVICES_APP end context 'GET /config/v1/services' do it 'will default to an empty list if the system config file is missing' do file = Tempfile.new('services') HWSSettings.system_handle.SERVICE_CONFIGURATION = file.path file.close file.unlink authorize 'jdoe', ticket_for_jdoe get('/config/v1/services') expect(last_response.status).to eq(200) services = JSON.parse(last_response.body) expect(services).to eq([]) end it 'will return the contents of the SERVICE_CONFIGURATION config file' do example = [ { 'type' => 'p4d', 'uri' => ['p4://perforce.example.com:1678'] } ] file = Tempfile.new('services') file.write(JSON.generate(example)) file.close HWSSettings.system_handle.SERVICE_CONFIGURATION = file.path authorize 'jdoe', ticket_for_jdoe get('/config/v1/services') expect(last_response.status).to eq(200) services = JSON.parse(last_response.body) expect(services).to eq(example) end end end