proxy_controller_spec.rb 1.06 KB
Newer Older
1 2 3 4
# frozen_string_literal: true

require 'spec_helper'

5
RSpec.describe CustomersDot::ProxyController, type: :request do
6 7 8 9
  describe 'POST graphql' do
    let_it_be(:customers_dot) { "#{Gitlab::SubscriptionPortal::SUBSCRIPTIONS_URL}/graphql" }

    it 'forwards request body to customers dot' do
10
      request_params = '{ "foo" => "bar" }'
11 12 13

      stub_request(:post, customers_dot)

14
      post customers_dot_proxy_graphql_path, params: request_params
15

16
      expect(WebMock).to have_requested(:post, customers_dot).with(body: request_params)
17 18 19 20 21
    end

    it 'responds with customers dot status' do
      stub_request(:post, customers_dot).to_return(status: 500)

22
      post customers_dot_proxy_graphql_path
23 24 25 26 27 28 29 30 31

      expect(response).to have_gitlab_http_status(:internal_server_error)
    end

    it 'responds with customers dot response body' do
      customers_dot_response = 'foo'

      stub_request(:post, customers_dot).to_return(body: customers_dot_response)

32
      post customers_dot_proxy_graphql_path
33 34 35 36 37

      expect(response.body).to eq(customers_dot_response)
    end
  end
end