diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-10-06 13:52:11 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-10-06 17:26:32 +0200 |
commit | 1f14e689e579163222fa0a410d3ab4ca672d465e (patch) | |
tree | 78b0d3b8723881766da6836ad6f11fda525192a7 | |
parent | fcc39d551977888fef161492cd47b502ed4c325b (diff) | |
download | gitlab-ce-1f14e689e579163222fa0a410d3ab4ca672d465e.tar.gz |
Added specs for TrendingProjectsFinder
-rw-r--r-- | spec/finders/trending_projects_finder_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/finders/trending_projects_finder_spec.rb b/spec/finders/trending_projects_finder_spec.rb new file mode 100644 index 00000000000..1ad2e23f1f1 --- /dev/null +++ b/spec/finders/trending_projects_finder_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe TrendingProjectsFinder do + let(:user) { create(:user) } + let(:group) { create(:group) } + + let(:project1) { create(:empty_project, :public, group: group) } + let(:project2) { create(:empty_project, :public, group: group) } + + before do + 2.times do + create(:note_on_commit, project: project1) + end + + create(:note_on_commit, project: project2) + end + + describe '#execute' do + describe 'without an explicit start date' do + subject { described_class.new.execute(user).to_a } + + it 'sorts Projects by the amount of notes in descending order' do + expect(subject).to eq([project1, project2]) + end + end + + describe 'with an explicit start date' do + let(:date) { 2.months.ago } + + subject { described_class.new.execute(user, date).to_a } + + before do + 2.times do + create(:note_on_commit, project: project2, created_at: date) + end + end + + it 'sorts Projects by the amount of notes in descending order' do + expect(subject).to eq([project2, project1]) + end + end + end +end |