diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2015-10-15 11:35:57 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2015-10-15 11:35:57 +0000 |
commit | daccc54d25a5acfd089e02fd7387ed14f0a3a629 (patch) | |
tree | 23022a603117e114ea608c7fa3e842a615f8faf6 /spec/models/ci/commit_spec.rb | |
parent | 524b3db30ca53449c13cb6bb9a518cfc2c0cacf7 (diff) | |
parent | 9fa209e1d8748b1eb1ef041bb1c40d30914f2815 (diff) | |
download | gitlab-ce-daccc54d25a5acfd089e02fd7387ed14f0a3a629.tar.gz |
Merge branch 'builds-view' into 'master'
Added builds view

/cc @dzaporozhets @vsizov
See merge request !1593
Diffstat (limited to 'spec/models/ci/commit_spec.rb')
-rw-r--r-- | spec/models/ci/commit_spec.rb | 18 |
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 |