blob: 757a73ed6121f832bfdd14b377c7c1b21ceb562e (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# 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
describe '#candidates_order_params' do
using RSpec::Parameterized::TableSyntax
subject { candidates_order_params(params) }
where(:input, :order_by, :order_by_type, :sort) do
'' | nil | nil | nil
'created_at' | 'created_at' | 'column' | nil
'created_at ASC' | 'created_at' | 'column' | 'ASC'
'metrics.something' | 'something' | 'metric' | nil
'metrics.something asc' | 'something' | 'metric' | 'asc'
'metrics.something.blah asc' | 'something' | 'metric' | 'asc'
'params.something ASC' | nil | nil | 'ASC'
'metadata.something ASC' | nil | nil | 'ASC'
end
with_them do
let(:params) { { order_by: input } }
it 'is correct' do
is_expected.to include({ order_by: order_by, order_by_type: order_by_type, sort: sort })
end
end
end
end
|