summaryrefslogtreecommitdiff
path: root/spec/models/project_spec.rb
diff options
context:
space:
mode:
author🙈 jacopo beschi 🙉 <intrip@gmail.com>2018-09-21 17:06:55 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-09-21 17:06:55 +0000
commitc49c596d17f8d8b62e29f2fd1344ce08cb0a0b93 (patch)
tree3656bb26d05d473afd779511a2646f398e4f3123 /spec/models/project_spec.rb
parent8f191590447d8e8aa375f1c1104540db5473ce51 (diff)
downloadgitlab-ce-c49c596d17f8d8b62e29f2fd1344ce08cb0a0b93.tar.gz
Allows to sort projects by most stars
Diffstat (limited to 'spec/models/project_spec.rb')
-rw-r--r--spec/models/project_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 909012b7789..567b66b54eb 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -1072,6 +1072,18 @@ describe Project do
it { expect(project.builds_enabled?).to be_truthy }
end
+ describe '.sort_by_attribute' do
+ it 'reorders the input relation by start count desc' do
+ project1 = create(:project, star_count: 2)
+ project2 = create(:project, star_count: 1)
+ project3 = create(:project)
+
+ projects = described_class.sort_by_attribute(:stars_desc)
+
+ expect(projects).to eq([project1, project2, project3])
+ end
+ end
+
describe '.with_shared_runners' do
subject { described_class.with_shared_runners }