Commit 3095483e650ae4fc79ff5012117877e5734b75ee

Authored by Robert Speicher
1 parent 3784f134

Speed up the "Project Network Graph" cucumber feature

This change involves stubbing out the call to `Grit::Commit.find_all`
and limiting the number of commits to 10 vs. the standard of 650 used by
`Gitlab::GraphCommit.to_graph`.

Prior to this change, this single feature required almost 3 minutes of
running time and over 2 GB of memory on my machine. Now it takes less
than 3 seconds.
features/projects/network.feature
@@ -4,9 +4,7 @@ Feature: Project Network Graph @@ -4,9 +4,7 @@ Feature: Project Network Graph
4 Background: 4 Background:
5 Given I signin as a user 5 Given I signin as a user
6 And I own project "Shop" 6 And I own project "Shop"
7 - And I visit project "Shop" network page 7 + And I visit project "Shop" network page
8 8
9 Scenario: I should see project network 9 Scenario: I should see project network
10 Then page should have network graph 10 Then page should have network graph
11 -  
12 -  
features/step_definitions/project/projects_steps.rb
@@ -57,6 +57,11 @@ end @@ -57,6 +57,11 @@ end
57 57
58 Given /^I visit project "(.*?)" network page$/ do |arg1| 58 Given /^I visit project "(.*?)" network page$/ do |arg1|
59 project = Project.find_by_name(arg1) 59 project = Project.find_by_name(arg1)
  60 +
  61 + # Stub out find_all to speed this up (10 commits vs. 650)
  62 + commits = Grit::Commit.find_all(project.repo, nil, {max_count: 10})
  63 + Grit::Commit.stub(:find_all).and_return(commits)
  64 +
60 visit graph_project_path(project) 65 visit graph_project_path(project)
61 end 66 end
62 67
@@ -67,8 +72,9 @@ end @@ -67,8 +72,9 @@ end
67 Given /^page should have network graph$/ do 72 Given /^page should have network graph$/ do
68 page.should have_content "Project Network Graph" 73 page.should have_content "Project Network Graph"
69 within ".graph" do 74 within ".graph" do
70 - page.should have_content "stable"  
71 - page.should have_content "notes_refacto..." 75 + page.should have_content "master"
  76 + page.should have_content "github"
  77 + page.should have_content "scss_refactor..."
72 end 78 end
73 end 79 end
74 80
features/support/env.rb
@@ -44,3 +44,5 @@ require 'headless' @@ -44,3 +44,5 @@ require 'headless'
44 44
45 headless = Headless.new 45 headless = Headless.new
46 headless.start 46 headless.start
  47 +
  48 +require 'cucumber/rspec/doubles'