summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2012-10-31 15:22:13 +0200
committerDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2012-10-31 15:22:13 +0200
commit2032f4cd9665d0b4244e30160c64996dc37c0a0e (patch)
tree0a9680412262efa4789c997c11b718f792de0175
parent9014fb7525504dedaaca3b586af028455dc4004b (diff)
downloadgitlab-ce-2032f4cd9665d0b4244e30160c64996dc37c0a0e.tar.gz
Fix tests fail cause of issue with grit stub
-rw-r--r--features/steps/project/project_network_graph.rb8
-rw-r--r--features/steps/shared/paths.rb5
-rw-r--r--lib/gitlab/graph_commit.rb18
3 files changed, 19 insertions, 12 deletions
diff --git a/features/steps/project/project_network_graph.rb b/features/steps/project/project_network_graph.rb
index f34a81a408d..e8aadf91764 100644
--- a/features/steps/project/project_network_graph.rb
+++ b/features/steps/project/project_network_graph.rb
@@ -11,12 +11,10 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
end
And 'I visit project "Shop" network page' do
- project = Project.find_by_name("Shop")
-
- # Stub out find_all to speed this up (10 commits vs. 650)
- commits = Grit::Commit.find_all(project.repo, nil, {max_count: 10})
- Grit::Commit.stub(:find_all).and_return(commits)
+ # Stub GraphCommit max_size to speed up test (10 commits vs. 650)
+ Gitlab::GraphCommit.stub(max_count: 10)
+ project = Project.find_by_name("Shop")
visit graph_project_path(project)
end
end
diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb
index b4e4b810c20..21936f19f47 100644
--- a/features/steps/shared/paths.rb
+++ b/features/steps/shared/paths.rb
@@ -122,9 +122,8 @@ module SharedPaths
end
Given "I visit my project's network page" do
- # Stub out find_all to speed this up (10 commits vs. 650)
- commits = Grit::Commit.find_all(@project.repo, nil, {max_count: 10})
- Grit::Commit.stub(:find_all).and_return(commits)
+ # Stub GraphCommit max_size to speed up test (10 commits vs. 650)
+ Gitlab::GraphCommit.stub(max_count: 10)
visit graph_project_path(@project)
end
diff --git a/lib/gitlab/graph_commit.rb b/lib/gitlab/graph_commit.rb
index 188fc422259..b1ac1a0223b 100644
--- a/lib/gitlab/graph_commit.rb
+++ b/lib/gitlab/graph_commit.rb
@@ -2,18 +2,18 @@ require "grit"
module Gitlab
class GraphCommit
- attr_accessor :time, :space
- attr_accessor :refs
+ attr_accessor :time, :space, :refs
include ActionView::Helpers::TagHelper
def self.to_graph(project)
@repo = project.repo
- commits = Grit::Commit.find_all(@repo, nil, {max_count: 650}).dup
+
+ commits = collect_commits(@repo).dup
ref_cache = {}
- commits.map! {|c| GraphCommit.new(Commit.new(c))}
+ commits.map! { |commit| GraphCommit.new(Commit.new(commit))}
commits.each { |commit| commit.add_refs(ref_cache, @repo) }
days = GraphCommit.index_commits(commits)
@@ -23,6 +23,16 @@ module Gitlab
return @days_json, @commits_json
end
+ # Get commits from repository
+ #
+ def self.collect_commits repo
+ Grit::Commit.find_all(repo, nil, {max_count: self.max_count})
+ end
+
+ def self.max_count
+ @max_count ||= 650
+ end
+
# Method is adding time and space on the
# list of commits. As well as returns date list
# corelated with time set on commits.