summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-09 15:17:20 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-09 15:17:20 +0000
commit3670ddd229b178c0a2e09a1466ddfd7fd2f7855d (patch)
tree9be2a8155e0b14fb9a07b6a1c8bcfa629af4a25c /spec/models
parent0b4adad74b76b34855e9a6d943f9b9188c3914fa (diff)
downloadgitlab-ce-3670ddd229b178c0a2e09a1466ddfd7fd2f7855d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ml/candidate_spec.rb19
-rw-r--r--spec/models/work_item_spec.rb14
2 files changed, 33 insertions, 0 deletions
diff --git a/spec/models/ml/candidate_spec.rb b/spec/models/ml/candidate_spec.rb
index a39babd78b7..fa19b723ee2 100644
--- a/spec/models/ml/candidate_spec.rb
+++ b/spec/models/ml/candidate_spec.rb
@@ -157,6 +157,9 @@ RSpec.describe Ml::Candidate, factory_default: :keep, feature_category: :mlops d
expect(subject.association_cached?(:latest_metrics)).to be(true)
expect(subject.association_cached?(:params)).to be(true)
expect(subject.association_cached?(:user)).to be(true)
+ expect(subject.association_cached?(:project)).to be(true)
+ expect(subject.association_cached?(:package)).to be(true)
+ expect(subject.association_cached?(:ci_build)).to be(true)
end
end
@@ -188,6 +191,22 @@ RSpec.describe Ml::Candidate, factory_default: :keep, feature_category: :mlops d
end
end
+ describe 'from_ci?' do
+ subject { candidate }
+
+ it 'is false if candidate does not have ci_build_id' do
+ allow(candidate).to receive(:ci_build_id).and_return(nil)
+
+ is_expected.not_to be_from_ci
+ end
+
+ it 'is true if candidate does has ci_build_id' do
+ allow(candidate).to receive(:ci_build_id).and_return(1)
+
+ is_expected.to be_from_ci
+ end
+ end
+
describe '#order_by_metric' do
let_it_be(:auc_metrics) do
create(:ml_candidate_metrics, name: 'auc', value: 0.4, candidate: candidate)
diff --git a/spec/models/work_item_spec.rb b/spec/models/work_item_spec.rb
index 57193d4ac49..24920421ae6 100644
--- a/spec/models/work_item_spec.rb
+++ b/spec/models/work_item_spec.rb
@@ -329,6 +329,20 @@ RSpec.describe WorkItem, feature_category: :portfolio_management do
end
end
+ describe '#link_reference_pattern' do
+ let(:match_data) { described_class.link_reference_pattern.match(link_reference_url) }
+
+ context 'with work item url' do
+ let(:link_reference_url) { 'http://localhost/namespace/project/-/work_items/1' }
+
+ it 'matches with expected attributes' do
+ expect(match_data['namespace']).to eq('namespace')
+ expect(match_data['project']).to eq('project')
+ expect(match_data['work_item']).to eq('1')
+ end
+ end
+ end
+
context 'with hierarchy' do
let_it_be(:type1) { create(:work_item_type, namespace: reusable_project.namespace) }
let_it_be(:type2) { create(:work_item_type, namespace: reusable_project.namespace) }