BigW Consortium Gitlab

trending_projects_finder_spec.rb 922 Bytes
Newer Older
1 2 3
require 'spec_helper'

describe TrendingProjectsFinder do
4
  let(:user) { build(:user) }
5 6 7

  describe '#execute' do
    describe 'without an explicit start date' do
8
      subject { described_class.new }
9

10 11 12 13 14 15 16 17 18
      it 'returns the trending projects' do
        relation = double(:ar_relation)

        allow(subject).to receive(:projects_for)
          .with(user)
          .and_return(relation)

        allow(relation).to receive(:trending)
          .with(an_instance_of(ActiveSupport::TimeWithZone))
19 20 21 22 23 24
      end
    end

    describe 'with an explicit start date' do
      let(:date) { 2.months.ago }

25
      subject { described_class.new }
26

27 28 29 30 31 32
      it 'returns the trending projects' do
        relation = double(:ar_relation)

        allow(subject).to receive(:projects_for)
          .with(user)
          .and_return(relation)
33

34 35
        allow(relation).to receive(:trending)
          .with(date)
36 37 38 39
      end
    end
  end
end