2015-10-06 07:52:11 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe TrendingProjectsFinder do
|
2015-10-06 10:35:51 -04:00
|
|
|
let(:user) { build(:user) }
|
2015-10-06 07:52:11 -04:00
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
describe 'without an explicit start date' do
|
2015-10-06 10:35:51 -04:00
|
|
|
subject { described_class.new }
|
2015-10-06 07:52:11 -04:00
|
|
|
|
2015-10-06 10:35:51 -04:00
|
|
|
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))
|
2015-10-06 07:52:11 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with an explicit start date' do
|
|
|
|
let(:date) { 2.months.ago }
|
|
|
|
|
2015-10-06 10:35:51 -04:00
|
|
|
subject { described_class.new }
|
2015-10-06 07:52:11 -04:00
|
|
|
|
2015-10-06 10:35:51 -04:00
|
|
|
it 'returns the trending projects' do
|
|
|
|
relation = double(:ar_relation)
|
|
|
|
|
|
|
|
allow(subject).to receive(:projects_for)
|
|
|
|
.with(user)
|
|
|
|
.and_return(relation)
|
2015-10-06 07:52:11 -04:00
|
|
|
|
2015-10-06 10:35:51 -04:00
|
|
|
allow(relation).to receive(:trending)
|
|
|
|
.with(date)
|
2015-10-06 07:52:11 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|