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:
authorTimothy Andrew <mail@timothyandrew.net>2017-04-26 12:23:22 +0300
committerTimothy Andrew <mail@timothyandrew.net>2017-04-27 16:09:54 +0300
commita7e67604b3c64a4a9e0cea6e0f9b1fa85d1c30af (patch)
tree2f581d58f6cb0fa20b5c83ef988835ee75a70b9c /spec/models/network
parent3c6fad64296738239582ad449bb202cfd99ba7ff (diff)
Fix ordering of commits in the network graph.
- We upgraded `rugged` to 0.25.1.1 in !10286 for %9.1 - Prior to this upgrade, the default sort order for commits returned by `Gitlab::Git::Repository#find_commits` was `Rugged::SORT_DATE`, which the graph relied on. - While upgrading `rugged`, the MR also changed this default to `Rugged::SORT_NONE`, which broke commit ordering in the graph. - This commit adds an option to `Gitlab::Git::Repository#find_commits` to sort by date, and changes the graph builder `Network::Graph` so it explictly requests the `:date` sort order
Diffstat (limited to 'spec/models/network')
-rw-r--r--spec/models/network/graph_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/models/network/graph_spec.rb b/spec/models/network/graph_spec.rb
index 492c4e01bd8..46b36e11c23 100644
--- a/spec/models/network/graph_spec.rb
+++ b/spec/models/network/graph_spec.rb
@@ -9,4 +9,25 @@ describe Network::Graph, models: true do
expect(graph.notes).to eq( { note_on_commit.commit_id => 1 } )
end
+
+ describe "#commits" do
+ let(:graph) { described_class.new(project, 'refs/heads/master', project.repository.commit, nil) }
+
+ it "returns a list of commits" do
+ commits = graph.commits
+
+ expect(commits).not_to be_empty
+ expect(commits).to all( be_kind_of(Network::Commit) )
+ end
+
+ it "sorts the commits by commit date (descending)" do
+ # Remove duplicate timestamps because they make it harder to
+ # assert that the commits are sorted as expected.
+ commits = graph.commits.uniq(&:date)
+ sorted_commits = commits.sort_by(&:date).reverse
+
+ expect(commits).not_to be_empty
+ expect(commits.map(&:id)).to eq(sorted_commits.map(&:id))
+ end
+ end
end