Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab_address.rb « support « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d978bb2eee553770f9c831fd3fff29139fdb3376 (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
46
47
48
# frozen_string_literal: true

module QA
  module Support
    class GitlabAddress
      class << self
        # Define gitlab address
        #
        # @param [String] address
        # @return [void]
        def define_gitlab_address_attribute!(address = Runtime::Env.gitlab_url)
          return if initialized?

          validate_address(address)

          Runtime::Scenario.define(:gitlab_address, address)
          # Define the "About" page as an `about` subdomain.
          # @example
          #   Given *gitlab_address* = 'https://gitlab.com/' #=> https://about.gitlab.com/
          #   Given *gitlab_address* = 'https://staging.gitlab.com/' #=> https://about.staging.gitlab.com/
          #   Given *gitlab_address* = 'http://gitlab-abc123.test/' #=> http://about.gitlab-abc123.test/
          Runtime::Scenario.define(:about_address, URI(address).tap { |uri| uri.host = "about.#{uri.host}" }.to_s)

          @initialized = true
        end

        private

        # Gitlab address already set up
        #
        # @return [Boolean]
        def initialized?
          @initialized
        end

        # Validate if address is a valid url
        #
        # @param [String] address
        # @return [void]
        def validate_address(address)
          Runtime::Address.valid?(address) || raise(
            ::ArgumentError, "Configured gitlab address is not a valid url: #{address}"
          )
        end
      end
    end
  end
end