Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
f112e2a1
Commit
f112e2a1
authored
Jun 20, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue with returning ref in commits JSON
Added tests to project controller
parent
c240cad5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
4 deletions
+24
-4
app/assets/javascripts/gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+1
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+3
-3
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+20
-0
No files found.
app/assets/javascripts/gl_dropdown.js.coffee
View file @
f112e2a1
...
@@ -102,7 +102,7 @@ class GitLabDropdownFilter
...
@@ -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
...
...
app/controllers/projects_controller.rb
View file @
f112e2a1
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?
...
@@ -261,8 +261,8 @@ class ProjectsController < Projects::ApplicationController
...
@@ -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
...
...
spec/controllers/projects_controller_spec.rb
View file @
f112e2a1
...
@@ -237,4 +237,24 @@ describe ProjectsController do
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment