Commit ac1b353e authored by Mateusz Bajorski's avatar Mateusz Bajorski

Refactor success status in branch controller

parent 896b9a68
...@@ -46,14 +46,16 @@ class Projects::BranchesController < Projects::ApplicationController ...@@ -46,14 +46,16 @@ class Projects::BranchesController < Projects::ApplicationController
result = CreateBranchService.new(project, current_user) result = CreateBranchService.new(project, current_user)
.execute(branch_name, ref) .execute(branch_name, ref)
if params[:issue_iid] && result[:status] == :success success = (result[:status] == :success)
if params[:issue_iid] && success
issue = IssuesFinder.new(current_user, project_id: @project.id).find_by(iid: params[:issue_iid]) issue = IssuesFinder.new(current_user, project_id: @project.id).find_by(iid: params[:issue_iid])
SystemNoteService.new_issue_branch(issue, @project, current_user, branch_name) if issue SystemNoteService.new_issue_branch(issue, @project, current_user, branch_name) if issue
end end
respond_to do |format| respond_to do |format|
format.html do format.html do
if result[:status] == :success if success
if redirect_to_autodeploy if redirect_to_autodeploy
redirect_to url_to_autodeploy_setup(project, branch_name), redirect_to url_to_autodeploy_setup(project, branch_name),
notice: view_context.autodeploy_flash_notice(branch_name) notice: view_context.autodeploy_flash_notice(branch_name)
...@@ -67,7 +69,7 @@ class Projects::BranchesController < Projects::ApplicationController ...@@ -67,7 +69,7 @@ class Projects::BranchesController < Projects::ApplicationController
end end
format.json do format.json do
if result[:status] == :success if success
render json: { name: branch_name, url: project_tree_url(@project, branch_name) } render json: { name: branch_name, url: project_tree_url(@project, branch_name) }
else else
render json: result[:messsage], status: :unprocessable_entity render json: result[:messsage], status: :unprocessable_entity
......
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