summaryrefslogtreecommitdiff
path: root/spec/support/webmock.rb
blob: 57acc3b63b1bd4359e912b8a4729f8a790bd82e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

require 'webmock'
require 'webmock/rspec'

def webmock_allowed_hosts
  %w[elasticsearch registry.gitlab.com-gitlab-org-test-elastic-image].tap do |hosts|
    if ENV.key?('ELASTIC_URL')
      hosts << URI.parse(ENV['ELASTIC_URL']).host
    end

    if Gitlab.config.webpack&.dev_server&.enabled
      hosts << Gitlab.config.webpack.dev_server.host
    end
  end.compact.uniq
end

WebMock.disable_net_connect!(allow_localhost: true, allow: webmock_allowed_hosts)