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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/ml/candidate_spec.rb')
-rw-r--r--spec/models/ml/candidate_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/models/ml/candidate_spec.rb b/spec/models/ml/candidate_spec.rb
index a48e291fa55..f58d30f81a0 100644
--- a/spec/models/ml/candidate_spec.rb
+++ b/spec/models/ml/candidate_spec.rb
@@ -9,4 +9,35 @@ RSpec.describe Ml::Candidate do
it { is_expected.to have_many(:params) }
it { is_expected.to have_many(:metrics) }
end
+
+ describe '#new' do
+ it 'iid is not null' do
+ expect(create(:ml_candidates).iid).not_to be_nil
+ end
+ end
+
+ describe 'by_project_id_and_iid' do
+ let_it_be(:candidate) { create(:ml_candidates) }
+
+ let(:project_id) { candidate.experiment.project_id }
+ let(:iid) { candidate.iid }
+
+ subject { described_class.with_project_id_and_iid(project_id, iid) }
+
+ context 'when iid exists', 'and belongs to project' do
+ it { is_expected.to eq(candidate) }
+ end
+
+ context 'when iid exists', 'and does not belong to project' do
+ let(:project_id) { non_existing_record_id }
+
+ it { is_expected.to be_nil }
+ end
+
+ context 'when iid does not exist' do
+ let(:iid) { 'a' }
+
+ it { is_expected.to be_nil }
+ end
+ end
end