summaryrefslogtreecommitdiff
path: root/spec/models/ci/commit_spec.rb
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2015-10-15 11:35:57 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2015-10-15 11:35:57 +0000
commitdaccc54d25a5acfd089e02fd7387ed14f0a3a629 (patch)
tree23022a603117e114ea608c7fa3e842a615f8faf6 /spec/models/ci/commit_spec.rb
parent524b3db30ca53449c13cb6bb9a518cfc2c0cacf7 (diff)
parent9fa209e1d8748b1eb1ef041bb1c40d30914f2815 (diff)
downloadgitlab-ce-daccc54d25a5acfd089e02fd7387ed14f0a3a629.tar.gz
Merge branch 'builds-view' into 'master'
Added builds view ![Screen_Shot_2015-10-13_at_19.02.48](https://gitlab.com/gitlab-org/gitlab-ce/uploads/95bb3a7d9d603678fdd077558637045d/Screen_Shot_2015-10-13_at_19.02.48.png) /cc @dzaporozhets @vsizov See merge request !1593
Diffstat (limited to 'spec/models/ci/commit_spec.rb')
-rw-r--r--spec/models/ci/commit_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/ci/commit_spec.rb b/spec/models/ci/commit_spec.rb
index 330971174fb..d1cecce5a6d 100644
--- a/spec/models/ci/commit_spec.rb
+++ b/spec/models/ci/commit_spec.rb
@@ -32,6 +32,24 @@ describe Ci::Commit do
it { is_expected.to respond_to :git_author_email }
it { is_expected.to respond_to :short_sha }
+ describe :ordered do
+ let(:project) { FactoryGirl.create :empty_project }
+
+ it 'returns ordered list of commits' do
+ commit1 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, gl_project: project
+ commit2 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, gl_project: project
+ expect(project.ci_commits.ordered).to eq([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, gl_project: project
+ commit2 = FactoryGirl.create :ci_commit, committed_at: nil, gl_project: project
+ commit3 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, gl_project: project
+ commit4 = FactoryGirl.create :ci_commit, committed_at: nil, gl_project: project
+ expect(project.ci_commits.ordered).to eq([commit2, commit4, commit3, commit1])
+ end
+ end
+
describe :last_build do
subject { commit.last_build }
before do