2019-12-20 04:24:38 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-09-24 23:09:30 -04:00
|
|
|
RSpec.describe QA::Runtime::ApplicationSettings do
|
2019-12-20 04:24:38 -05:00
|
|
|
let(:api_client) { double('QA::Runtime::API::Client') }
|
|
|
|
let(:request) { Struct.new(:url).new('http://api') }
|
|
|
|
let(:get_response) { Struct.new(:body).new("{}") }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(described_class).to receive(:api_client).and_return(api_client)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.set_application_settings' do
|
|
|
|
it 'sets application settings' do
|
|
|
|
expect(QA::Runtime::API::Request)
|
|
|
|
.to receive(:new)
|
|
|
|
.with(api_client, '/application/settings')
|
|
|
|
.and_return(request)
|
|
|
|
|
2020-09-14 02:09:28 -04:00
|
|
|
expect(described_class).to receive(:get_application_settings)
|
|
|
|
|
2019-12-20 04:24:38 -05:00
|
|
|
expect(described_class)
|
|
|
|
.to receive(:put)
|
|
|
|
.with(request.url, { allow_local_requests_from_web_hooks_and_services: true })
|
|
|
|
.and_return(Struct.new(:code).new(200))
|
|
|
|
|
2020-09-14 02:09:28 -04:00
|
|
|
described_class.set_application_settings(allow_local_requests_from_web_hooks_and_services: true)
|
2019-12-20 04:24:38 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.get_application_settings' do
|
|
|
|
it 'gets application settings' do
|
|
|
|
expect(QA::Runtime::API::Request)
|
|
|
|
.to receive(:new)
|
|
|
|
.with(api_client, '/application/settings')
|
|
|
|
.and_return(request)
|
|
|
|
|
|
|
|
expect(described_class)
|
|
|
|
.to receive(:get)
|
|
|
|
.with(request.url)
|
|
|
|
.and_return(get_response)
|
|
|
|
|
2020-09-14 02:09:28 -04:00
|
|
|
described_class.get_application_settings
|
2019-12-20 04:24:38 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|