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

candidate_metric_spec.rb « ml « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9f9a6e8e3ba9db42899aaca50640656796992928 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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