Commit 0bef4b97 authored by Felipe Artur's avatar Felipe Artur

Implement review suggestions

parent 32c7e42b
...@@ -14,6 +14,7 @@ v 8.7.0 (unreleased) ...@@ -14,6 +14,7 @@ v 8.7.0 (unreleased)
- Handle nil descriptions in Slack issue messages (Stan Hu) - Handle nil descriptions in Slack issue messages (Stan Hu)
- Add default scope to projects to exclude projects pending deletion - Add default scope to projects to exclude projects pending deletion
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.) - 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.) - Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu) - Gracefully handle notes on deleted commits in merge requests (Stan Hu)
- Fix creation of merge requests for orphaned branches (Stan Hu) - Fix creation of merge requests for orphaned branches (Stan Hu)
......
...@@ -21,7 +21,7 @@ class Groups::MilestonesController < Groups::ApplicationController ...@@ -21,7 +21,7 @@ class Groups::MilestonesController < Groups::ApplicationController
project_ids = params[:milestone][:project_ids].reject(&:blank?) project_ids = params[:milestone][:project_ids].reject(&:blank?)
title = milestone_params[:title] title = milestone_params[:title]
if create_milestones(project_ids, title) if create_milestones(project_ids)
redirect_to milestone_path(title) redirect_to milestone_path(title)
else else
render_new_with_error(project_ids.empty?) render_new_with_error(project_ids.empty?)
...@@ -41,7 +41,7 @@ class Groups::MilestonesController < Groups::ApplicationController ...@@ -41,7 +41,7 @@ class Groups::MilestonesController < Groups::ApplicationController
private private
def create_milestones(project_ids, title) def create_milestones(project_ids)
return false unless project_ids.present? return false unless project_ids.present?
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
...@@ -51,9 +51,7 @@ class Groups::MilestonesController < Groups::ApplicationController ...@@ -51,9 +51,7 @@ class Groups::MilestonesController < Groups::ApplicationController
end end
true true
rescue ActiveRecord::ActiveRecordError => e
rescue => e
flash.now[:alert] = "An error occurred while creating the milestone: #{e.message}" flash.now[:alert] = "An error occurred while creating the milestone: #{e.message}"
false false
end end
......
...@@ -3,7 +3,7 @@ module Milestones ...@@ -3,7 +3,7 @@ module Milestones
def execute def execute
milestone = project.milestones.new(params) milestone = project.milestones.new(params)
if milestone.save if milestone.save!
event_service.open_milestone(milestone, current_user) event_service.open_milestone(milestone, current_user)
end end
......
...@@ -27,7 +27,7 @@ describe Groups::MilestonesController do ...@@ -27,7 +27,7 @@ describe Groups::MilestonesController do
it "redirects to new when there are no project ids" do it "redirects to new when there are no project ids" do
post :create, group_id: group.id, milestone: { title: title, project_ids: [""] } post :create, group_id: group.id, milestone: { title: title, project_ids: [""] }
expect(response).to render_template :new expect(response).to render_template :new
expect(assigns(:milestone).errors).to_not be_nil expect(assigns(:milestone).errors).not_to be_nil
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment