Commit b0a02384 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Reload merge request association reload when update code

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 8e031ce3
...@@ -246,13 +246,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -246,13 +246,7 @@ class MergeRequest < ActiveRecord::Base
end end
def diff_refs def diff_refs
return unless diff_start_commit || diff_base_commit merge_request_diff.diff_refs
Gitlab::Diff::DiffRefs.new(
base_sha: diff_base_sha,
start_sha: diff_start_sha,
head_sha: diff_head_sha
)
end end
def validate_branches def validate_branches
...@@ -306,6 +300,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -306,6 +300,7 @@ 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(
......
...@@ -291,7 +291,7 @@ describe MergeRequest, models: true do ...@@ -291,7 +291,7 @@ describe MergeRequest, models: true do
end end
it "can be removed if the last commit is the head of the source branch" do it "can be removed if the last commit is the head of the source branch" do
allow(subject.source_project).to receive(:commit).and_return(subject.diff_head_commit) allow(subject).to receive(:source_branch_head).and_return(subject.diff_head_commit)
expect(subject.can_remove_source_branch?(user)).to be_truthy expect(subject.can_remove_source_branch?(user)).to be_truthy
end end
...@@ -655,7 +655,7 @@ describe MergeRequest, models: true do ...@@ -655,7 +655,7 @@ describe MergeRequest, models: true do
let(:commit) { subject.project.commit(sample_commit.id) } let(:commit) { subject.project.commit(sample_commit.id) }
it "does not change existing merge request diff" do it "does not change existing merge request diff" do
expect(subject.merge_request_diff).not_to receive(:reload_content) expect(subject.merge_request_diff).not_to receive(:save_git_content)
subject.reload_diff subject.reload_diff
end end
...@@ -669,7 +669,6 @@ describe MergeRequest, models: true do ...@@ -669,7 +669,6 @@ describe MergeRequest, models: true do
# Update merge_request_diff so that #diff_refs will return commit.diff_refs # Update merge_request_diff so that #diff_refs will return commit.diff_refs
allow(subject).to receive(:create_merge_request_diff) do allow(subject).to receive(:create_merge_request_diff) do
subject.merge_request_diffs.create( subject.merge_request_diffs.create(
importing: true,
base_commit_sha: commit.parent_id, base_commit_sha: commit.parent_id,
start_commit_sha: commit.parent_id, start_commit_sha: commit.parent_id,
head_commit_sha: commit.sha head_commit_sha: commit.sha
......
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