diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-10-14 14:07:41 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-10-14 17:28:38 +0200 |
commit | 09255eecd0812d35b09613a1cf2402d3108fcc49 (patch) | |
tree | 1e04881ed6a65819ed8d5c690f463941832f355c /spec/models/ci/commit_spec.rb | |
parent | a957eca6f364b7587175a6ffa647fc9df80abed9 (diff) | |
download | gitlab-ce-09255eecd0812d35b09613a1cf2402d3108fcc49.tar.gz |
Remove ordering from :ci_commits relation
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 |