Module: API::Helpers::RelatedResourcesHelpers

Instance Method Summary collapse

Instance Method Details

#expose_path(path) ⇒ Object


16
17
18
# File 'lib/api/helpers/related_resources_helpers.rb', line 16

def expose_path(path)
  Gitlab::Utils.append_path(Gitlab.config.gitlab.relative_url_root, path)
end

#expose_url(path) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
# File 'lib/api/helpers/related_resources_helpers.rb', line 20

def expose_url(path)
  url_options = Gitlab::Application.routes.default_url_options
  protocol, host, port, script_name = url_options.values_at(:protocol, :host, :port, :script_name)

  # Using a blank component at the beginning of the join we ensure
  # that the resulted path will start with '/'. If the resulted path
  # does not start with '/', URI::Generic#build will fail
  path_with_script_name = File.join('', [script_name, path].select(&:present?))

  URI::Generic.build(scheme: protocol, host: host, port: port, path: path_with_script_name).to_s
end

#issues_available?(project, options) ⇒ Boolean

Returns:

  • (Boolean)

8
9
10
# File 'lib/api/helpers/related_resources_helpers.rb', line 8

def issues_available?(project, options)
  available?(:issues, project, options[:current_user])
end

#mrs_available?(project, options) ⇒ Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/api/helpers/related_resources_helpers.rb', line 12

def mrs_available?(project, options)
  available?(:merge_requests, project, options[:current_user])
end