Commit 4b3afe23 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Always create merge_request_diff if MR created

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 94865a60
......@@ -76,7 +76,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request.author = current_user
@target_branches ||= []
if @merge_request.save
@merge_request.reload_code
redirect_to [@merge_request.target_project, @merge_request], notice: 'Merge request was successfully created.'
else
@source_project = @merge_request.source_project
......
......@@ -30,7 +30,9 @@ class MergeRequest < ActiveRecord::Base
belongs_to :target_project, foreign_key: :target_project_id, class_name: "Project"
belongs_to :source_project, foreign_key: :source_project_id, class_name: "Project"
has_one :merge_request_diff, dependent: :destroy
after_create :create_merge_request_diff
delegate :commits, :diffs, :last_commit, :last_commit_short_sha, to: :merge_request_diff, prefix: nil
......
......@@ -6,7 +6,6 @@ class MergeRequestObserver < ActivityObserver
create_event(merge_request, Event.determine_action(merge_request))
end
merge_request.create_merge_request_diff
notification.new_merge_request(merge_request, current_user)
merge_request.create_cross_references!(merge_request.project, current_user)
execute_hooks(merge_request)
......
......@@ -88,7 +88,6 @@ module API
end
if merge_request.save
merge_request.reload_code
present merge_request, with: Entities::MergeRequest
else
handle_merge_request_errors! merge_request.errors
......
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