mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-21 10:36:04 +10:00
Fixed issue with returning ref in commits JSON
Added tests to project controller
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user