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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
745c1f56
Commit
745c1f56
authored
Dec 18, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
64770965
aa2c729e
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
195 additions
and
68 deletions
+195
-68
app/assets/javascripts/behaviors/shortcuts/shortcuts_navigation.js
...s/javascripts/behaviors/shortcuts/shortcuts_navigation.js
+1
-0
app/controllers/projects/releases_controller.rb
app/controllers/projects/releases_controller.rb
+5
-28
app/controllers/projects/tags/releases_controller.rb
app/controllers/projects/tags/releases_controller.rb
+42
-0
app/controllers/projects/tags_controller.rb
app/controllers/projects/tags_controller.rb
+2
-2
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+2
-2
app/views/layouts/nav/sidebar/_project.html.haml
app/views/layouts/nav/sidebar/_project.html.haml
+6
-1
app/views/projects/releases/index.html.haml
app/views/projects/releases/index.html.haml
+5
-0
app/views/projects/tags/releases/edit.html.haml
app/views/projects/tags/releases/edit.html.haml
+0
-0
config/routes/project.rb
config/routes/project.rb
+1
-0
config/routes/repository.rb
config/routes/repository.rb
+1
-1
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/controllers/projects/releases_controller_spec.rb
spec/controllers/projects/releases_controller_spec.rb
+44
-34
spec/controllers/projects/tags/releases_controller_spec.rb
spec/controllers/projects/tags/releases_controller_spec.rb
+57
-0
spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+26
-0
No files found.
app/assets/javascripts/behaviors/shortcuts/shortcuts_navigation.js
View file @
745c1f56
...
@@ -8,6 +8,7 @@ export default class ShortcutsNavigation extends Shortcuts {
...
@@ -8,6 +8,7 @@ export default class ShortcutsNavigation extends Shortcuts {
Mousetrap
.
bind
(
'
g p
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-project
'
));
Mousetrap
.
bind
(
'
g p
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-project
'
));
Mousetrap
.
bind
(
'
g v
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-project-activity
'
));
Mousetrap
.
bind
(
'
g v
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-project-activity
'
));
Mousetrap
.
bind
(
'
g r
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-project-releases
'
));
Mousetrap
.
bind
(
'
g f
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-tree
'
));
Mousetrap
.
bind
(
'
g f
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-tree
'
));
Mousetrap
.
bind
(
'
g c
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-commits
'
));
Mousetrap
.
bind
(
'
g c
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-commits
'
));
Mousetrap
.
bind
(
'
g j
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-builds
'
));
Mousetrap
.
bind
(
'
g j
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-builds
'
));
...
...
app/controllers/projects/releases_controller.rb
View file @
745c1f56
...
@@ -4,39 +4,16 @@ class Projects::ReleasesController < Projects::ApplicationController
...
@@ -4,39 +4,16 @@ class Projects::ReleasesController < Projects::ApplicationController
# Authorize
# Authorize
before_action
:require_non_empty_project
before_action
:require_non_empty_project
before_action
:authorize_download_code!
before_action
:authorize_download_code!
before_action
:authorize_push_code!
before_action
:check_releases_page_feature_flag
before_action
:tag
before_action
:release
def
edit
def
index
end
def
update
# Release belongs to Tag which is not active record object,
# it exists only to save a description to each Tag.
# If description is empty we should destroy the existing record.
if
release_params
[
:description
].
present?
release
.
update
(
release_params
)
else
release
.
destroy
end
redirect_to
project_tag_path
(
@project
,
@tag
.
name
)
end
end
private
private
def
tag
def
check_releases_page_feature_flag
@tag
||=
@repository
.
find_tag
(
params
[
:tag_id
])
return
render_404
unless
Feature
.
enabled?
(
:releases_page
)
end
# rubocop: disable CodeReuse/ActiveRecord
def
release
@release
||=
@project
.
releases
.
find_or_initialize_by
(
tag:
@tag
.
name
)
end
# rubocop: enable CodeReuse/ActiveRecord
def
release_params
push_frontend_feature_flag
(
:releases_page
)
params
.
require
(
:release
).
permit
(
:description
)
end
end
end
end
app/controllers/projects/tags/releases_controller.rb
0 → 100644
View file @
745c1f56
# frozen_string_literal: true
class
Projects::Tags::ReleasesController
<
Projects
::
ApplicationController
# Authorize
before_action
:require_non_empty_project
before_action
:authorize_download_code!
before_action
:authorize_push_code!
before_action
:tag
before_action
:release
def
edit
end
def
update
# Release belongs to Tag which is not active record object,
# it exists only to save a description to each Tag.
# If description is empty we should destroy the existing record.
if
release_params
[
:description
].
present?
release
.
update
(
release_params
)
else
release
.
destroy
end
redirect_to
project_tag_path
(
@project
,
@tag
.
name
)
end
private
def
tag
@tag
||=
@repository
.
find_tag
(
params
[
:tag_id
])
end
# rubocop: disable CodeReuse/ActiveRecord
def
release
@release
||=
@project
.
releases
.
find_or_initialize_by
(
tag:
@tag
.
name
)
end
# rubocop: enable CodeReuse/ActiveRecord
def
release_params
params
.
require
(
:release
).
permit
(
:description
)
end
end
app/controllers/projects/tags_controller.rb
View file @
745c1f56
...
@@ -42,7 +42,7 @@ class Projects::TagsController < Projects::ApplicationController
...
@@ -42,7 +42,7 @@ class Projects::TagsController < Projects::ApplicationController
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
create
def
create
result
=
Tags
::
CreateService
.
new
(
@project
,
current_user
)
result
=
::
Tags
::
CreateService
.
new
(
@project
,
current_user
)
.
execute
(
params
[
:tag_name
],
params
[
:ref
],
params
[
:message
],
params
[
:release_description
])
.
execute
(
params
[
:tag_name
],
params
[
:ref
],
params
[
:message
],
params
[
:release_description
])
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
...
@@ -58,7 +58,7 @@ class Projects::TagsController < Projects::ApplicationController
...
@@ -58,7 +58,7 @@ class Projects::TagsController < Projects::ApplicationController
end
end
def
destroy
def
destroy
result
=
Tags
::
DestroyService
.
new
(
project
,
current_user
).
execute
(
params
[
:id
])
result
=
::
Tags
::
DestroyService
.
new
(
project
,
current_user
).
execute
(
params
[
:id
])
respond_to
do
|
format
|
respond_to
do
|
format
|
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
...
...
app/helpers/projects_helper.rb
View file @
745c1f56
...
@@ -279,7 +279,7 @@ module ProjectsHelper
...
@@ -279,7 +279,7 @@ module ProjectsHelper
nav_tabs
=
[
:home
]
nav_tabs
=
[
:home
]
if
!
project
.
empty_repo?
&&
can?
(
current_user
,
:download_code
,
project
)
if
!
project
.
empty_repo?
&&
can?
(
current_user
,
:download_code
,
project
)
nav_tabs
<<
[
:files
,
:commits
,
:network
,
:graphs
,
:forks
]
nav_tabs
<<
[
:files
,
:commits
,
:network
,
:graphs
,
:forks
,
:releases
]
end
end
if
project
.
repo_exists?
&&
can?
(
current_user
,
:read_merge_request
,
project
)
if
project
.
repo_exists?
&&
can?
(
current_user
,
:read_merge_request
,
project
)
...
@@ -535,6 +535,7 @@ module ProjectsHelper
...
@@ -535,6 +535,7 @@ module ProjectsHelper
%w[
%w[
projects#show
projects#show
projects#activity
projects#activity
releases#index
cycle_analytics#show
cycle_analytics#show
]
]
end
end
...
@@ -566,7 +567,6 @@ module ProjectsHelper
...
@@ -566,7 +567,6 @@ module ProjectsHelper
projects/repositories
projects/repositories
tags
tags
branches
branches
releases
graphs
graphs
network
network
]
]
...
...
app/views/layouts/nav/sidebar/_project.html.haml
View file @
745c1f56
...
@@ -29,6 +29,11 @@
...
@@ -29,6 +29,11 @@
=
link_to
activity_project_path
(
@project
),
title:
_
(
'Activity'
),
class:
'shortcuts-project-activity'
do
=
link_to
activity_project_path
(
@project
),
title:
_
(
'Activity'
),
class:
'shortcuts-project-activity'
do
%span
=
_
(
'Activity'
)
%span
=
_
(
'Activity'
)
-
if
project_nav_tab?
(
:releases
)
&&
Feature
.
enabled?
(
:releases_page
)
=
nav_link
(
controller: :releases
)
do
=
link_to
project_releases_path
(
@project
),
title:
_
(
'Releases'
),
class:
'shortcuts-project-releases'
do
%span
=
_
(
'Releases'
)
=
render_if_exists
'projects/sidebar/security_dashboard'
=
render_if_exists
'projects/sidebar/security_dashboard'
-
if
can?
(
current_user
,
:read_cycle_analytics
,
@project
)
-
if
can?
(
current_user
,
:read_cycle_analytics
,
@project
)
...
@@ -62,7 +67,7 @@
...
@@ -62,7 +67,7 @@
=
link_to
project_branches_path
(
@project
)
do
=
link_to
project_branches_path
(
@project
)
do
=
_
(
'Branches'
)
=
_
(
'Branches'
)
=
nav_link
(
controller:
[
:tags
,
:releases
])
do
=
nav_link
(
controller:
[
:tags
])
do
=
link_to
project_tags_path
(
@project
)
do
=
link_to
project_tags_path
(
@project
)
do
=
_
(
'Tags'
)
=
_
(
'Tags'
)
...
...
app/views/projects/releases/index.html.haml
0 → 100644
View file @
745c1f56
-
@no_container
=
true
-
page_title
_
(
'Releases'
)
%div
{
'class'
=>
container_class
}
#js-releases-page
app/views/projects/releases/edit.html.haml
→
app/views/projects/
tags/
releases/edit.html.haml
View file @
745c1f56
File moved
config/routes/project.rb
View file @
745c1f56
...
@@ -102,6 +102,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
...
@@ -102,6 +102,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
end
end
resources
:releases
,
only:
[
:index
]
resources
:forks
,
only:
[
:index
,
:new
,
:create
]
resources
:forks
,
only:
[
:index
,
:new
,
:create
]
resource
:import
,
only:
[
:new
,
:create
,
:show
]
resource
:import
,
only:
[
:new
,
:create
,
:show
]
...
...
config/routes/repository.rb
View file @
745c1f56
...
@@ -55,7 +55,7 @@ scope format: false do
...
@@ -55,7 +55,7 @@ scope format: false do
resources
:branches
,
only:
[
:index
,
:new
,
:create
,
:destroy
]
resources
:branches
,
only:
[
:index
,
:new
,
:create
,
:destroy
]
delete
:merged_branches
,
controller:
'branches'
,
action: :destroy_all_merged
delete
:merged_branches
,
controller:
'branches'
,
action: :destroy_all_merged
resources
:tags
,
only:
[
:index
,
:show
,
:new
,
:create
,
:destroy
]
do
resources
:tags
,
only:
[
:index
,
:show
,
:new
,
:create
,
:destroy
]
do
resource
:release
,
only:
[
:edit
,
:update
]
resource
:release
,
controller:
'tags/releases'
,
only:
[
:edit
,
:update
]
end
end
resources
:protected_branches
,
only:
[
:index
,
:show
,
:create
,
:update
,
:destroy
,
:patch
],
constraints:
{
id:
Gitlab
::
PathRegex
.
git_reference_regex
}
resources
:protected_branches
,
only:
[
:index
,
:show
,
:create
,
:update
,
:destroy
,
:patch
],
constraints:
{
id:
Gitlab
::
PathRegex
.
git_reference_regex
}
...
...
locale/gitlab.pot
View file @
745c1f56
...
@@ -7172,6 +7172,9 @@ msgstr ""
...
@@ -7172,6 +7172,9 @@ msgstr ""
msgid "Related merge requests"
msgid "Related merge requests"
msgstr ""
msgstr ""
msgid "Releases"
msgstr ""
msgid "Remind later"
msgid "Remind later"
msgstr ""
msgstr ""
...
...
spec/controllers/projects/releases_controller_spec.rb
View file @
745c1f56
# frozen_string_literal: true
require
'spec_helper'
require
'spec_helper'
describe
Projects
::
ReleasesController
do
describe
Projects
::
ReleasesController
do
let!
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
let!
(
:user
)
{
create
(
:user
)
}
let!
(
:user
)
{
create
(
:user
)
}
let!
(
:release
)
{
create
(
:release
,
project:
project
)
}
let!
(
:tag
)
{
release
.
tag
}
before
do
before
do
project
.
add_developer
(
user
)
stub_feature_flags
(
releases_page:
true
)
sign_in
(
user
)
end
end
describe
'GET #edit'
do
describe
'GET #index'
do
it
'initializes a new release'
do
it
'renders a 200'
do
tag_id
=
release
.
tag
get_index
project
.
releases
.
destroy_all
# rubocop: disable DestroyAll
get
:edit
,
namespace_id:
project
.
namespace
,
project_id:
project
,
tag_id:
tag_id
expect
(
response
.
status
).
to
eq
(
200
)
release
=
assigns
(
:release
)
expect
(
release
).
not_to
be_nil
expect
(
release
).
not_to
be_persisted
end
end
it
'retrieves an existing release'
do
context
'when the project is private'
do
get
:edit
,
namespace_id:
project
.
namespace
,
project_id:
project
,
tag_id:
release
.
tag
let!
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
it
'renders a 302'
do
get_index
release
=
assigns
(
:release
)
expect
(
response
.
status
).
to
eq
(
302
)
expect
(
release
).
not_to
be_nil
expect
(
release
).
to
be_persisted
end
end
it
'renders a 200 for a logged in developer'
do
project
.
add_developer
(
user
)
sign_in
(
user
)
get_index
expect
(
response
.
status
).
to
eq
(
200
)
end
end
describe
'PUT #update'
do
it
'renders a 404 when logged in but not in the project'
do
it
'updates release note description'
do
sign_in
(
user
)
update_release
(
'description updated'
)
get_index
release
=
project
.
releases
.
find_by_tag
(
tag
)
expect
(
response
.
status
).
to
eq
(
404
)
e
xpect
(
release
.
description
).
to
eq
(
"description updated"
)
e
nd
end
end
it
'deletes release note when description is null'
do
context
'when releases_page feature flag is disabled'
do
expect
{
update_release
(
''
)
}.
to
change
(
project
.
releases
,
:count
).
by
(
-
1
)
before
do
stub_feature_flags
(
releases_page:
false
)
end
it
'renders a 404'
do
get_index
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
end
end
private
def
update_release
(
description
)
def
get_index
put
:update
,
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
tag_id:
release
.
tag
,
release:
{
description:
description
}
end
end
end
end
spec/controllers/projects/tags/releases_controller_spec.rb
0 → 100644
View file @
745c1f56
# frozen_string_literal: true
require
'spec_helper'
describe
Projects
::
Tags
::
ReleasesController
do
let!
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:user
)
{
create
(
:user
)
}
let!
(
:release
)
{
create
(
:release
,
project:
project
)
}
let!
(
:tag
)
{
release
.
tag
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
end
describe
'GET #edit'
do
it
'initializes a new release'
do
tag_id
=
release
.
tag
project
.
releases
.
destroy_all
# rubocop: disable DestroyAll
get
:edit
,
namespace_id:
project
.
namespace
,
project_id:
project
,
tag_id:
tag_id
release
=
assigns
(
:release
)
expect
(
release
).
not_to
be_nil
expect
(
release
).
not_to
be_persisted
end
it
'retrieves an existing release'
do
get
:edit
,
namespace_id:
project
.
namespace
,
project_id:
project
,
tag_id:
release
.
tag
release
=
assigns
(
:release
)
expect
(
release
).
not_to
be_nil
expect
(
release
).
to
be_persisted
end
end
describe
'PUT #update'
do
it
'updates release note description'
do
update_release
(
'description updated'
)
release
=
project
.
releases
.
find_by_tag
(
tag
)
expect
(
release
.
description
).
to
eq
(
"description updated"
)
end
it
'deletes release note when description is null'
do
expect
{
update_release
(
''
)
}.
to
change
(
project
.
releases
,
:count
).
by
(
-
1
)
end
end
def
update_release
(
description
)
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
tag_id:
release
.
tag
,
release:
{
description:
description
}
end
end
spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
View file @
745c1f56
...
@@ -58,4 +58,30 @@ describe 'layouts/nav/sidebar/_project' do
...
@@ -58,4 +58,30 @@ describe 'layouts/nav/sidebar/_project' do
expect
(
rendered
).
to
have_css
(
'.sidebar-top-level-items > li.active'
,
text:
'Registry'
)
expect
(
rendered
).
to
have_css
(
'.sidebar-top-level-items > li.active'
,
text:
'Registry'
)
end
end
end
end
describe
'releases entry'
do
describe
'when releases feature flag is disabled'
do
before
do
stub_feature_flags
(
releases_page:
false
)
end
it
'does not render releases link'
do
render
expect
(
rendered
).
not_to
have_link
(
'Releases'
,
href:
project_releases_path
(
project
))
end
end
describe
'when releases feature flags is enabled'
do
before
do
stub_feature_flags
(
releases_page:
true
)
end
it
'renders releases link'
do
render
expect
(
rendered
).
to
have_link
(
'Releases'
,
href:
project_releases_path
(
project
))
end
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