debian-mirror-gitlab/spec/models/ml/candidate_metric_spec.rb
2023-01-13 15:02:22 +05:30

22 lines
676 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ml::CandidateMetric do
describe 'associations' do
it { is_expected.to belong_to(:candidate) }
end
describe 'scope :latest' do
let_it_be(:candidate) { create(:ml_candidates) }
let!(:metric1) { create(:ml_candidate_metrics, candidate: candidate) }
let!(:metric2) { create(:ml_candidate_metrics, candidate: candidate ) }
let!(:metric3) { create(:ml_candidate_metrics, name: metric1.name, candidate: candidate) }
subject { described_class.latest }
it 'fetches only the last metric for the name' do
expect(subject).to match_array([metric2, metric3] )
end
end
end