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

api_helpers_spec.rb « mlflow « ml « api « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4f6a37c66c491d4a90503657b30ee2805223eb0b (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe API::Ml::Mlflow::ApiHelpers, feature_category: :mlops do
  include described_class

  describe '#packages_url' do
    subject { packages_url }

    let_it_be(:user_project) { build_stubbed(:project) }

    context 'with an empty relative URL root' do
      before do
        allow(Gitlab::Application.routes).to receive(:default_url_options)
          .and_return(protocol: 'http', host: 'localhost', script_name: '')
      end

      it { is_expected.to eql("http://localhost/api/v4/projects/#{user_project.id}/packages/generic") }
    end

    context 'with a forward slash relative URL root' do
      before do
        allow(Gitlab::Application.routes).to receive(:default_url_options)
          .and_return(protocol: 'http', host: 'localhost', script_name: '/')
      end

      it { is_expected.to eql("http://localhost/api/v4/projects/#{user_project.id}/packages/generic") }
    end

    context 'with a relative URL root' do
      before do
        allow(Gitlab::Application.routes).to receive(:default_url_options)
          .and_return(protocol: 'http', host: 'localhost', script_name: '/gitlab/root')
      end

      it { is_expected.to eql("http://localhost/gitlab/root/api/v4/projects/#{user_project.id}/packages/generic") }
    end
  end
end