summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-06-20 11:37:27 +0100
committerPhil Hughes <me@iamphill.com>2016-06-20 11:37:27 +0100
commitf112e2a1da696905e994bf5c37c10a950779b1a9 (patch)
treed4b42a4b7c959bf6b742fd7e87b76f4a3d7493dd
parentc240cad59a84e090e12d7ce6db94983405aa1813 (diff)
downloadgitlab-ce-async-refs-dropdown.tar.gz
Fixed issue with returning ref in commits JSONasync-refs-dropdown
Added tests to project controller
-rw-r--r--app/assets/javascripts/gl_dropdown.js.coffee2
-rw-r--r--app/controllers/projects_controller.rb6
-rw-r--r--spec/controllers/projects_controller_spec.rb20
3 files changed, 24 insertions, 4 deletions
diff --git a/app/assets/javascripts/gl_dropdown.js.coffee b/app/assets/javascripts/gl_dropdown.js.coffee
index f8a2db6d42c..2a7bf0bc306 100644
--- a/app/assets/javascripts/gl_dropdown.js.coffee
+++ b/app/assets/javascripts/gl_dropdown.js.coffee
@@ -102,7 +102,7 @@ class GitLabDropdownFilter
$el = $(@)
matches = fuzzaldrinPlus.match($el.text().trim(), search_text)
- if $el.is(':not(.dropdown-header)')
+ unless $el.is('.dropdown-header')
if matches.length
$el.show()
else
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index b65730b37c9..78ceaf3237f 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -1,7 +1,7 @@
class ProjectsController < Projects::ApplicationController
include ExtractsPath
- before_action :authenticate_user!, except: [:show, :activity]
+ before_action :authenticate_user!, except: [:show, :activity, :refs]
before_action :project, except: [:new, :create]
before_action :repository, except: [:new, :create]
before_action :assign_ref_vars, :tree, only: [:show], if: :repo_exists?
@@ -261,8 +261,8 @@ class ProjectsController < Projects::ApplicationController
end
# If reference is commit id - we should add it to branch/tag selectbox
- ref = params[:ref]
- if ref && options.flatten.exclude?(ref) && ref =~ /\A[0-9a-zA-Z]{6,52}\z/
+ ref = Addressable::URI.unescape(params[:ref])
+ if ref && options.flatten(2).exclude?(ref) && ref =~ /\A[0-9a-zA-Z]{6,52}\z/
options['Commits'] = [ref]
end
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index fba545560c7..146b2c2e131 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -237,4 +237,24 @@ describe ProjectsController do
expect(response.status).to eq(401)
end
end
+
+ describe "GET refs" do
+ it "should get a list of branches and tags" do
+ get :refs, namespace_id: public_project.namespace.path, id: public_project.path
+
+ parsed_body = JSON.parse(response.body)
+ expect(parsed_body["Branches"]).to include("master")
+ expect(parsed_body["Tags"]).to include("v1.0.0")
+ expect(parsed_body["Commits"]).to be_nil
+ end
+
+ it "should get a list of branches, tags and commits" do
+ get :refs, namespace_id: public_project.namespace.path, id: public_project.path, ref: "123456"
+
+ parsed_body = JSON.parse(response.body)
+ expect(parsed_body["Branches"]).to include("master")
+ expect(parsed_body["Tags"]).to include("v1.0.0")
+ expect(parsed_body["Commits"]).to include("123456")
+ end
+ end
end