Skip to content
Snippets Groups Projects
Commit f112e2a1 authored by Phil Hughes's avatar Phil Hughes
Browse files

Fixed issue with returning ref in commits JSON

Added tests to project controller
parent c240cad5
No related branches found
No related tags found
1 merge request!4508Refs dropdown is now loaded async
Pipeline #
Loading
@@ -102,7 +102,7 @@ class GitLabDropdownFilter
Loading
@@ -102,7 +102,7 @@ class GitLabDropdownFilter
$el = $(@) $el = $(@)
matches = fuzzaldrinPlus.match($el.text().trim(), search_text) matches = fuzzaldrinPlus.match($el.text().trim(), search_text)
   
if $el.is(':not(.dropdown-header)') unless $el.is('.dropdown-header')
if matches.length if matches.length
$el.show() $el.show()
else else
Loading
Loading
class ProjectsController < Projects::ApplicationController class ProjectsController < Projects::ApplicationController
include ExtractsPath 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 :project, except: [:new, :create]
before_action :repository, except: [:new, :create] before_action :repository, except: [:new, :create]
before_action :assign_ref_vars, :tree, only: [:show], if: :repo_exists? before_action :assign_ref_vars, :tree, only: [:show], if: :repo_exists?
Loading
@@ -261,8 +261,8 @@ class ProjectsController < Projects::ApplicationController
Loading
@@ -261,8 +261,8 @@ class ProjectsController < Projects::ApplicationController
end end
   
# If reference is commit id - we should add it to branch/tag selectbox # If reference is commit id - we should add it to branch/tag selectbox
ref = params[:ref] ref = Addressable::URI.unescape(params[:ref])
if ref && options.flatten.exclude?(ref) && ref =~ /\A[0-9a-zA-Z]{6,52}\z/ if ref && options.flatten(2).exclude?(ref) && ref =~ /\A[0-9a-zA-Z]{6,52}\z/
options['Commits'] = [ref] options['Commits'] = [ref]
end end
   
Loading
Loading
Loading
@@ -237,4 +237,24 @@ describe ProjectsController do
Loading
@@ -237,4 +237,24 @@ describe ProjectsController do
expect(response.status).to eq(401) expect(response.status).to eq(401)
end end
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 end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment