about summary refs log tree commit diff
path: root/spec/models/preview_card_provider_spec.rb
blob: 7425b939462f699862ea12c6d7b3848da24c5627 (plain) (blame)
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
# frozen_string_literal: true

require 'rails_helper'

describe PreviewCardProvider do
  describe 'scopes' do
    let(:trendable_and_reviewed) { Fabricate(:preview_card_provider, trendable: true, reviewed_at: 5.days.ago) }
    let(:not_trendable_and_not_reviewed) { Fabricate(:preview_card_provider, trendable: false, reviewed_at: nil) }

    describe 'trendable' do
      it 'returns the relevant records' do
        results = described_class.trendable

        expect(results).to eq([trendable_and_reviewed])
      end
    end

    describe 'not_trendable' do
      it 'returns the relevant records' do
        results = described_class.not_trendable

        expect(results).to eq([not_trendable_and_not_reviewed])
      end
    end

    describe 'reviewed' do
      it 'returns the relevant records' do
        results = described_class.reviewed

        expect(results).to eq([trendable_and_reviewed])
      end
    end

    describe 'pending_review' do
      it 'returns the relevant records' do
        results = described_class.pending_review

        expect(results).to eq([not_trendable_and_not_reviewed])
      end
    end
  end
end