summaryrefslogtreecommitdiff
path: root/qa/spec/runtime/application_settings_spec.rb
blob: 5c4947f6f7099286dca0db6dda539ee1c2785bba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true

RSpec.describe QA::Runtime::ApplicationSettings do
  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)

      expect(described_class).to receive(:get_application_settings)

      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))

      described_class.set_application_settings(allow_local_requests_from_web_hooks_and_services: true)
    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)

      described_class.get_application_settings
    end
  end
end