BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
074c2393
Commit
074c2393
authored
Apr 07, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue_14012' into 'master'
Fix problem when creating milestones in groups without projects Fixes #14012 See merge request !3481
parents
9cae1403
0bef4b97
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
6 deletions
+42
-6
CHANGELOG
CHANGELOG
+1
-0
milestones_controller.rb
app/controllers/groups/milestones_controller.rb
+26
-5
create_service.rb
app/services/milestones/create_service.rb
+1
-1
new.html.haml
app/views/groups/milestones/new.html.haml
+8
-0
milestones_controller_spec.rb
spec/controllers/groups/milestones_controller_spec.rb
+6
-0
No files found.
CHANGELOG
View file @
074c2393
...
...
@@ -20,6 +20,7 @@ v 8.7.0 (unreleased)
- Ensure empty recipients are rejected in BuildsEmailService
- API: Ability to filter milestones by state `active` and `closed` (Robert Schilling)
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Better errors handling when creating milestones inside groups
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu)
- Fix creation of merge requests for orphaned branches (Stan Hu)
...
...
app/controllers/groups/milestones_controller.rb
View file @
074c2393
...
...
@@ -18,14 +18,14 @@ class Groups::MilestonesController < Groups::ApplicationController
end
def
create
project_ids
=
params
[
:milestone
][
:project_ids
]
project_ids
=
params
[
:milestone
][
:project_ids
]
.
reject
(
&
:blank?
)
title
=
milestone_params
[
:title
]
@projects
.
where
(
id:
project_ids
).
each
do
|
project
|
Milestones
::
CreateService
.
new
(
project
,
current_user
,
milestone_params
).
execute
end
if
create_milestones
(
project_ids
)
redirect_to
milestone_path
(
title
)
else
render_new_with_error
(
project_ids
.
empty?
)
end
end
def
show
...
...
@@ -41,6 +41,27 @@ class Groups::MilestonesController < Groups::ApplicationController
private
def
create_milestones
(
project_ids
)
return
false
unless
project_ids
.
present?
ActiveRecord
::
Base
.
transaction
do
@projects
.
where
(
id:
project_ids
).
each
do
|
project
|
Milestones
::
CreateService
.
new
(
project
,
current_user
,
milestone_params
).
execute
end
end
true
rescue
ActiveRecord
::
ActiveRecordError
=>
e
flash
.
now
[
:alert
]
=
"An error occurred while creating the milestone:
#{
e
.
message
}
"
false
end
def
render_new_with_error
(
empty_project_ids
)
@milestone
=
Milestone
.
new
(
milestone_params
)
@milestone
.
errors
.
add
(
:project_id
,
"Please select at least one project."
)
if
empty_project_ids
render
:new
end
def
authorize_admin_milestones!
return
render_404
unless
can?
(
current_user
,
:admin_milestones
,
group
)
end
...
...
app/services/milestones/create_service.rb
View file @
074c2393
...
...
@@ -3,7 +3,7 @@ module Milestones
def
execute
milestone
=
project
.
milestones
.
new
(
params
)
if
milestone
.
save
if
milestone
.
save
!
event_service
.
open_milestone
(
milestone
,
current_user
)
end
...
...
app/views/groups/milestones/new.html.haml
View file @
074c2393
...
...
@@ -10,6 +10,14 @@
=
form_for
@milestone
,
url:
group_milestones_path
(
@group
),
html:
{
class:
'form-horizontal milestone-form gfm-form js-quick-submit js-requires-input'
}
do
|
f
|
.row
-
if
@milestone
.
errors
.
any?
#error_explanation
.alert.alert-danger
%ul
-
@milestone
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
.col-md-6
.form-group
=
f
.
label
:title
,
"Title"
,
class:
"control-label"
...
...
spec/controllers/groups/milestones_controller_spec.rb
View file @
074c2393
...
...
@@ -23,5 +23,11 @@ describe Groups::MilestonesController do
expect
(
response
).
to
redirect_to
(
group_milestone_path
(
group
,
title
.
to_slug
.
to_s
,
title:
title
))
expect
(
Milestone
.
where
(
title:
title
).
count
).
to
eq
(
2
)
end
it
"redirects to new when there are no project ids"
do
post
:create
,
group_id:
group
.
id
,
milestone:
{
title:
title
,
project_ids:
[
""
]
}
expect
(
response
).
to
render_template
:new
expect
(
assigns
(
:milestone
).
errors
).
not_to
be_nil
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