summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-07-30 09:39:28 +0000
committerDouwe Maan <douwe@gitlab.com>2015-07-30 09:39:28 +0000
commit1e4b3264637a5b66a9bfb04fe9444bcf1f7e18ed (patch)
treeb0041914dbabbf56d9487b7faa113b7d032f7179
parentae36842d456f2bd028c8848f2e009141516087ee (diff)
parent369275d63074e5d526c0d1cf404b4a3742bb1e6a (diff)
downloadgitlab-ce-1e4b3264637a5b66a9bfb04fe9444bcf1f7e18ed.tar.gz
Merge branch 'fix-single-quote-in-network-graph' into 'master'
Fix network graph when branch name has single quotes ## Steps to reproduce 1. Create a branch with a single quote in the branch name: "`test`" 2. Look at Project's Network view Closes https://github.com/gitlabhq/gitlabhq/issues/9500 See merge request !1063
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/projects/network_controller.rb4
-rw-r--r--app/views/projects/network/show.html.haml6
-rw-r--r--features/project/network_graph.feature5
-rw-r--r--features/steps/project/network_graph.rb14
5 files changed, 25 insertions, 5 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 1aa3f13f168..c03e5053d17 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
Please view this file on the master branch, on stable branches it's out of date.
v 7.14.0 (unreleased)
+ - Fix network graph when branch name has single quotes (Stan Hu)
- Upgrade gitlab_git to version 7.2.6 to fix Error 500 when creating network graphs (Stan Hu)
- Fix URL used for refreshing notes if relative_url is present (Bartłomiej Święcki)
- Fix commit data retrieval when branch name has single quotes (Stan Hu)
diff --git a/app/controllers/projects/network_controller.rb b/app/controllers/projects/network_controller.rb
index 06aef91cadd..b181c47baec 100644
--- a/app/controllers/projects/network_controller.rb
+++ b/app/controllers/projects/network_controller.rb
@@ -7,6 +7,10 @@ class Projects::NetworkController < Projects::ApplicationController
before_action :authorize_download_code!
def show
+
+ @url = namespace_project_network_path(@project.namespace, @project, @ref, @options.merge(format: :json))
+ @commit_url = namespace_project_commit_path(@project.namespace, @project, 'ae45ca32').gsub("ae45ca32", "%s")
+
respond_to do |format|
format.html
diff --git a/app/views/projects/network/show.html.haml b/app/views/projects/network/show.html.haml
index a88cf167511..52b5b8b877e 100644
--- a/app/views/projects/network/show.html.haml
+++ b/app/views/projects/network/show.html.haml
@@ -17,9 +17,9 @@
:javascript
network_graph = new Network({
- url: '#{namespace_project_network_path(@project.namespace, @project, @ref, @options.merge(format: :json))}',
- commit_url: '#{namespace_project_commit_path(@project.namespace, @project, 'ae45ca32').gsub("ae45ca32", "%s")}',
- ref: '#{@ref}',
+ url: "#{escape_javascript(@url)}",
+ commit_url: "#{escape_javascript(@commit_url)}",
+ ref: "#{escape_javascript(@ref)}",
commit_id: '#{@commit.id}'
})
new ShortcutsNetwork(network_graph.branch_graph)
diff --git a/features/project/network_graph.feature b/features/project/network_graph.feature
index 8beb6043aff..6cc89a15a78 100644
--- a/features/project/network_graph.feature
+++ b/features/project/network_graph.feature
@@ -11,6 +11,11 @@ Feature: Project Network Graph
And page should have "master" on graph
@javascript
+ Scenario: I should see project network with 'test' branch
+ When I visit project network page on branch 'test'
+ Then page should have 'test' on graph
+
+ @javascript
Scenario: I should switch "branch" and "tag"
When I switch ref to "feature"
Then page should select "feature" in select box
diff --git a/features/steps/project/network_graph.rb b/features/steps/project/network_graph.rb
index 992cf2734fd..7a83d32a240 100644
--- a/features/steps/project/network_graph.rb
+++ b/features/steps/project/network_graph.rb
@@ -11,8 +11,12 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps
# Stub Graph max_size to speed up test (10 commits vs. 650)
Network::Graph.stub(max_count: 10)
- project = Project.find_by(name: "Shop")
- visit namespace_project_network_path(project.namespace, project, "master")
+ @project = Project.find_by(name: "Shop")
+ visit namespace_project_network_path(@project.namespace, @project, "master")
+ end
+
+ step "I visit project network page on branch 'test'" do
+ visit namespace_project_network_path(@project.namespace, @project, "'test'")
end
step 'page should select "master" in select box' do
@@ -29,6 +33,12 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps
end
end
+ step "page should have 'test' on graph" do
+ page.within '.network-graph' do
+ expect(page).to have_content "'test'"
+ end
+ end
+
When 'I switch ref to "feature"' do
select 'feature', from: 'ref'
sleep 2