Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-09-16 17:59:54 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2015-09-16 17:59:54 +0300
commit912f470497129b0d8759b18700299e38535e7bec (patch)
tree47d58838d15fb6de49f2e3a335df43db9e5b0348 /spec/models
parent1b2a1d0ddd39ecc530c64563d0083e1e255f7c1a (diff)
Fix ordering issue
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/project_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/ci/project_spec.rb b/spec/models/ci/project_spec.rb
index 1025868da6e..a6fd6f27942 100644
--- a/spec/models/ci/project_spec.rb
+++ b/spec/models/ci/project_spec.rb
@@ -61,6 +61,24 @@ describe Ci::Project do
end
end
+ describe 'ordered commits' do
+ let (:project) { FactoryGirl.create :ci_project }
+
+ it 'returns ordered list of commits' do
+ commit1 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, project: project
+ commit2 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, project: project
+ project.commits.should == [commit2, commit1]
+ end
+
+ it 'returns commits ordered by committed_at and id, with nulls last' do
+ commit1 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, project: project
+ commit2 = FactoryGirl.create :ci_commit, committed_at: nil, project: project
+ commit3 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, project: project
+ commit4 = FactoryGirl.create :ci_commit, committed_at: nil, project: project
+ project.commits.should == [commit2, commit4, commit3, commit1]
+ end
+ end
+
context :valid_project do
let(:project) { FactoryGirl.create :ci_project }