Commit 2032f4cd9665d0b4244e30160c64996dc37c0a0e
1 parent
9014fb75
Exists in
master
and in
4 other branches
Fix tests fail cause of issue with grit stub
Showing
3 changed files
with
19 additions
and
12 deletions
Show diff stats
features/steps/project/project_network_graph.rb
| ... | ... | @@ -11,12 +11,10 @@ class ProjectNetworkGraph < Spinach::FeatureSteps |
| 11 | 11 | end |
| 12 | 12 | |
| 13 | 13 | And 'I visit project "Shop" network page' do |
| 14 | - project = Project.find_by_name("Shop") | |
| 15 | - | |
| 16 | - # Stub out find_all to speed this up (10 commits vs. 650) | |
| 17 | - commits = Grit::Commit.find_all(project.repo, nil, {max_count: 10}) | |
| 18 | - Grit::Commit.stub(:find_all).and_return(commits) | |
| 14 | + # Stub GraphCommit max_size to speed up test (10 commits vs. 650) | |
| 15 | + Gitlab::GraphCommit.stub(max_count: 10) | |
| 19 | 16 | |
| 17 | + project = Project.find_by_name("Shop") | |
| 20 | 18 | visit graph_project_path(project) |
| 21 | 19 | end |
| 22 | 20 | end | ... | ... |
features/steps/shared/paths.rb
| ... | ... | @@ -122,9 +122,8 @@ module SharedPaths |
| 122 | 122 | end |
| 123 | 123 | |
| 124 | 124 | Given "I visit my project's network page" do |
| 125 | - # Stub out find_all to speed this up (10 commits vs. 650) | |
| 126 | - commits = Grit::Commit.find_all(@project.repo, nil, {max_count: 10}) | |
| 127 | - Grit::Commit.stub(:find_all).and_return(commits) | |
| 125 | + # Stub GraphCommit max_size to speed up test (10 commits vs. 650) | |
| 126 | + Gitlab::GraphCommit.stub(max_count: 10) | |
| 128 | 127 | |
| 129 | 128 | visit graph_project_path(@project) |
| 130 | 129 | end | ... | ... |
lib/gitlab/graph_commit.rb
| ... | ... | @@ -2,18 +2,18 @@ require "grit" |
| 2 | 2 | |
| 3 | 3 | module Gitlab |
| 4 | 4 | class GraphCommit |
| 5 | - attr_accessor :time, :space | |
| 6 | - attr_accessor :refs | |
| 5 | + attr_accessor :time, :space, :refs | |
| 7 | 6 | |
| 8 | 7 | include ActionView::Helpers::TagHelper |
| 9 | 8 | |
| 10 | 9 | def self.to_graph(project) |
| 11 | 10 | @repo = project.repo |
| 12 | - commits = Grit::Commit.find_all(@repo, nil, {max_count: 650}).dup | |
| 11 | + | |
| 12 | + commits = collect_commits(@repo).dup | |
| 13 | 13 | |
| 14 | 14 | ref_cache = {} |
| 15 | 15 | |
| 16 | - commits.map! {|c| GraphCommit.new(Commit.new(c))} | |
| 16 | + commits.map! { |commit| GraphCommit.new(Commit.new(commit))} | |
| 17 | 17 | commits.each { |commit| commit.add_refs(ref_cache, @repo) } |
| 18 | 18 | |
| 19 | 19 | days = GraphCommit.index_commits(commits) |
| ... | ... | @@ -23,6 +23,16 @@ module Gitlab |
| 23 | 23 | return @days_json, @commits_json |
| 24 | 24 | end |
| 25 | 25 | |
| 26 | + # Get commits from repository | |
| 27 | + # | |
| 28 | + def self.collect_commits repo | |
| 29 | + Grit::Commit.find_all(repo, nil, {max_count: self.max_count}) | |
| 30 | + end | |
| 31 | + | |
| 32 | + def self.max_count | |
| 33 | + @max_count ||= 650 | |
| 34 | + end | |
| 35 | + | |
| 26 | 36 | # Method is adding time and space on the |
| 27 | 37 | # list of commits. As well as returns date list |
| 28 | 38 | # corelated with time set on commits. | ... | ... |