Commit 7cb8ceb5 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix creation and reload of the merge request diff

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 6515ec09
No related merge requests found
...@@ -11,7 +11,9 @@ class MergeRequest < ActiveRecord::Base ...@@ -11,7 +11,9 @@ class MergeRequest < ActiveRecord::Base
belongs_to :merge_user, class_name: "User" belongs_to :merge_user, class_name: "User"
has_many :merge_request_diffs, dependent: :destroy has_many :merge_request_diffs, dependent: :destroy
has_one :merge_request_diff has_one :merge_request_diff,
-> { order('merge_request_diffs.id DESC') }
has_many :events, as: :target, dependent: :destroy has_many :events, as: :target, dependent: :destroy
serialize :merge_params, Hash serialize :merge_params, Hash
...@@ -287,6 +289,15 @@ class MergeRequest < ActiveRecord::Base ...@@ -287,6 +289,15 @@ class MergeRequest < ActiveRecord::Base
merge_request_diff || create_merge_request_diff merge_request_diff || create_merge_request_diff
end end
def create_merge_request_diff
merge_request_diffs.create
reload_merge_request_diff
end
def reload_merge_request_diff
merge_request_diff(true)
end
def reload_diff_if_branch_changed def reload_diff_if_branch_changed
if source_branch_changed? || target_branch_changed? if source_branch_changed? || target_branch_changed?
reload_diff reload_diff
...@@ -298,7 +309,6 @@ class MergeRequest < ActiveRecord::Base ...@@ -298,7 +309,6 @@ class MergeRequest < ActiveRecord::Base
old_diff_refs = self.diff_refs old_diff_refs = self.diff_refs
create_merge_request_diff create_merge_request_diff
merge_request_diffs.reload
new_diff_refs = self.diff_refs new_diff_refs = self.diff_refs
update_diff_notes_positions( update_diff_notes_positions(
......
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