diff options
Diffstat (limited to 'spec/lib/api/ml/mlflow/api_helpers_spec.rb')
-rw-r--r-- | spec/lib/api/ml/mlflow/api_helpers_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/lib/api/ml/mlflow/api_helpers_spec.rb b/spec/lib/api/ml/mlflow/api_helpers_spec.rb new file mode 100644 index 00000000000..4f6a37c66c4 --- /dev/null +++ b/spec/lib/api/ml/mlflow/api_helpers_spec.rb @@ -0,0 +1,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 |