summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/project_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index aa76b99..b6027a8 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -61,6 +61,24 @@ describe Project do
end
end
+ describe 'ordered commits' do
+ let (:project) { FactoryGirl.create :project }
+
+ it 'returns ordered list of commits' do
+ commit1 = FactoryGirl.create :commit, committed_at: 1.hour.ago, project: project
+ commit2 = FactoryGirl.create :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 :commit, committed_at: 1.hour.ago, project: project
+ commit2 = FactoryGirl.create :commit, committed_at: nil, project: project
+ commit3 = FactoryGirl.create :commit, committed_at: 2.hour.ago, project: project
+ commit4 = FactoryGirl.create :commit, committed_at: nil, project: project
+ project.commits.should == [commit2, commit4, commit3, commit1]
+ end
+ end
+
context :valid_project do
let(:project) { FactoryGirl.create :project }