From 038d40f0f5b202fe9ed133fdf9de1774bdbc8ede Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Tue, 11 Jun 2013 09:54:01 +0300
Subject: [PATCH] Solve inconsistency between network graph & stat graphs

---
 ...stat_graph_controller.rb => graphs_controller.rb} |  2 +-
 .../{graph_controller.rb => network_controller.rb}   |  2 +-
 app/controllers/refs_controller.rb                   |  2 +-
 app/views/{stat_graph => graphs}/show.html.haml      |  0
 app/views/{stat_graph => graphs}/show.js.haml        |  0
 app/views/layouts/nav/_project.html.haml             |  8 ++++----
 app/views/{graph => network}/_head.html.haml         |  4 ++--
 app/views/{graph => network}/show.html.haml          |  2 +-
 app/views/{graph => network}/show.json.erb           |  0
 config/routes.rb                                     |  4 ++--
 features/steps/project/project_graph.rb              |  2 +-
 features/steps/project/project_network_graph.rb      |  2 +-
 features/steps/shared/paths.rb                       |  2 +-
 spec/routing/project_routing_spec.rb                 | 12 +++++++++---
 14 files changed, 24 insertions(+), 18 deletions(-)
 rename app/controllers/{stat_graph_controller.rb => graphs_controller.rb} (87%)
 rename app/controllers/{graph_controller.rb => network_controller.rb} (90%)
 rename app/views/{stat_graph => graphs}/show.html.haml (100%)
 rename app/views/{stat_graph => graphs}/show.js.haml (100%)
 rename app/views/{graph => network}/_head.html.haml (86%)
 rename app/views/{graph => network}/show.html.haml (84%)
 rename app/views/{graph => network}/show.json.erb (100%)

diff --git a/app/controllers/stat_graph_controller.rb b/app/controllers/graphs_controller.rb
similarity index 87%
rename from app/controllers/stat_graph_controller.rb
rename to app/controllers/graphs_controller.rb
index f076f4726d0..5ae9c15c0f7 100644
--- a/app/controllers/stat_graph_controller.rb
+++ b/app/controllers/graphs_controller.rb
@@ -1,4 +1,4 @@
-class StatGraphController < ProjectResourceController
+class GraphsController < ProjectResourceController
   # Authorize
   before_filter :authorize_read_project!
   before_filter :authorize_code_access!
diff --git a/app/controllers/graph_controller.rb b/app/controllers/network_controller.rb
similarity index 90%
rename from app/controllers/graph_controller.rb
rename to app/controllers/network_controller.rb
index c79ed5ca3cc..3c8e747ba4e 100644
--- a/app/controllers/graph_controller.rb
+++ b/app/controllers/network_controller.rb
@@ -1,4 +1,4 @@
-class GraphController < ProjectResourceController
+class NetworkController < ProjectResourceController
   include ExtractsPath
   include ApplicationHelper
 
diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb
index e7def3984f8..cae9193a1da 100644
--- a/app/controllers/refs_controller.rb
+++ b/app/controllers/refs_controller.rb
@@ -14,7 +14,7 @@ class RefsController < ProjectResourceController
                    elsif params[:destination] == "blob"
                      project_blob_path(@project, (@id))
                    elsif params[:destination] == "graph"
-                     project_graph_path(@project, @id, @options)
+                     project_network_path(@project, @id, @options)
                    else
                      project_commits_path(@project, @id)
                    end
diff --git a/app/views/stat_graph/show.html.haml b/app/views/graphs/show.html.haml
similarity index 100%
rename from app/views/stat_graph/show.html.haml
rename to app/views/graphs/show.html.haml
diff --git a/app/views/stat_graph/show.js.haml b/app/views/graphs/show.js.haml
similarity index 100%
rename from app/views/stat_graph/show.js.haml
rename to app/views/graphs/show.js.haml
diff --git a/app/views/layouts/nav/_project.html.haml b/app/views/layouts/nav/_project.html.haml
index 399bcf5de2e..1c5781daab0 100644
--- a/app/views/layouts/nav/_project.html.haml
+++ b/app/views/layouts/nav/_project.html.haml
@@ -9,10 +9,10 @@
         = link_to 'Files', project_tree_path(@project, @ref || @repository.root_ref)
       = nav_link(controller: %w(commit commits compare repositories protected_branches)) do
         = link_to "Commits", project_commits_path(@project, @ref || @repository.root_ref)
-      = nav_link(controller: %w(graph)) do
-        = link_to "Network", project_graph_path(@project, @ref || @repository.root_ref)
-      = nav_link(controller: %w(stat_graph)) do
-        = link_to "Graphs", project_stat_graph_path(@project, @ref || @repository.root_ref)
+      = nav_link(controller: %w(network)) do
+        = link_to "Network", project_network_path(@project, @ref || @repository.root_ref)
+      = nav_link(controller: %w(graphs)) do
+        = link_to "Graphs", project_graph_path(@project, @ref || @repository.root_ref)
 
   - if @project.issues_enabled
     = nav_link(controller: %w(issues milestones labels)) do
diff --git a/app/views/graph/_head.html.haml b/app/views/network/_head.html.haml
similarity index 86%
rename from app/views/graph/_head.html.haml
rename to app/views/network/_head.html.haml
index 7a5b3c6f43d..62ab8b049ac 100644
--- a/app/views/graph/_head.html.haml
+++ b/app/views/network/_head.html.haml
@@ -5,7 +5,7 @@
   .pull-left
     = render partial: 'shared/ref_switcher', locals: {destination: 'graph'}
   .pull-left
-    = form_tag project_graph_path(@project, @id), method: :get do |f|
+    = form_tag project_network_path(@project, @id), method: :get do |f|
       .control-group
         = label_tag :filter_ref, "Show only selected ref", class: 'control-label light'
         .controls
@@ -14,7 +14,7 @@
       = hidden_field_tag(key, value, id: nil) unless key == "filter_ref"
 
   .search.pull-right
-    = form_tag project_graph_path(@project, @id), method: :get do |f|
+    = form_tag project_network_path(@project, @id), method: :get do |f|
       .control-group
         = label_tag :search , "Looking for commit:", class: 'control-label light'
         .controls
diff --git a/app/views/graph/show.html.haml b/app/views/network/show.html.haml
similarity index 84%
rename from app/views/graph/show.html.haml
rename to app/views/network/show.html.haml
index 0ee6648317c..a480ceaf995 100644
--- a/app/views/graph/show.html.haml
+++ b/app/views/network/show.html.haml
@@ -11,7 +11,7 @@
     $(this).closest('form').submit();
   });
   branch_graph = new BranchGraph($("#holder"), {
-    url: '#{project_graph_path(@project, @ref, @options.merge(format: :json))}',
+    url: '#{project_network_path(@project, @ref, @options.merge(format: :json))}',
     commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}',
     ref: '#{@ref}',
     commit_id: '#{@commit.id}'
diff --git a/app/views/graph/show.json.erb b/app/views/network/show.json.erb
similarity index 100%
rename from app/views/graph/show.json.erb
rename to app/views/network/show.json.erb
diff --git a/config/routes.rb b/config/routes.rb
index c555cd0b361..a50f78c616b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -190,8 +190,8 @@ Gitlab::Application.routes.draw do
     resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
     resources :compare, only: [:index, :create]
     resources :blame,   only: [:show], constraints: {id: /.+/}
-    resources :graph,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
-    resources :stat_graph, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
+    resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
+    resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
     match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/}
 
     scope module: :projects do
diff --git a/features/steps/project/project_graph.rb b/features/steps/project/project_graph.rb
index 489485b1dc4..50942b3cbb3 100644
--- a/features/steps/project/project_graph.rb
+++ b/features/steps/project/project_graph.rb
@@ -8,6 +8,6 @@ class ProjectGraph < Spinach::FeatureSteps
 
   When 'I visit project "Shop" graph page' do
     project = Project.find_by_name("Shop")
-    visit project_stat_graph_path(project, "master")
+    visit project_graph_path(project, "master")
   end
 end
diff --git a/features/steps/project/project_network_graph.rb b/features/steps/project/project_network_graph.rb
index 48a73f09fac..f001c0beb9a 100644
--- a/features/steps/project/project_network_graph.rb
+++ b/features/steps/project/project_network_graph.rb
@@ -12,7 +12,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
     Network::Graph.stub(max_count: 10)
 
     project = Project.find_by_name("Shop")
-    visit project_graph_path(project, "master")
+    visit project_network_path(project, "master")
   end
 
   And 'page should select "master" in select box' do
diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb
index 3641e788662..21b6159bce3 100644
--- a/features/steps/shared/paths.rb
+++ b/features/steps/shared/paths.rb
@@ -149,7 +149,7 @@ module SharedPaths
     # Stub Graph max_size to speed up test (10 commits vs. 650)
     Network::Graph.stub(max_count: 10)
 
-    visit project_graph_path(@project, root_ref)
+    visit project_network_path(@project, root_ref)
   end
 
   step "I visit my project's issues page" do
diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb
index 94f9480a4d0..a1d4bd6a4cd 100644
--- a/spec/routing/project_routing_spec.rb
+++ b/spec/routing/project_routing_spec.rb
@@ -446,9 +446,15 @@ describe CompareController, "routing" do
   end
 end
 
-describe GraphController, "routing" do
+describe NetworkController, "routing" do
   it "to #show" do
-    get("/gitlabhq/graph/master").should route_to('graph#show', project_id: 'gitlabhq', id: 'master')
-    get("/gitlabhq/graph/master.json").should route_to('graph#show', project_id: 'gitlabhq', id: 'master', format: "json")
+    get("/gitlabhq/network/master").should route_to('network#show', project_id: 'gitlabhq', id: 'master')
+    get("/gitlabhq/network/master.json").should route_to('network#show', project_id: 'gitlabhq', id: 'master', format: "json")
+  end
+end
+
+describe GraphsController, "routing" do
+  it "to #show" do
+    get("/gitlabhq/graphs/master").should route_to('graphs#show', project_id: 'gitlabhq', id: 'master')
   end
 end
-- 
GitLab