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
end
def diff_refs
return unless diff_start_commit || diff_base_commit
Gitlab::Diff::DiffRefs.new(
base_sha: diff_base_sha,
start_sha: diff_start_sha,
head_sha: diff_head_sha
)
merge_request_diff.diff_refs
end
def validate_branches
......@@ -306,6 +300,7 @@ class MergeRequest < ActiveRecord::Base
old_diff_refs = self.diff_refs
create_merge_request_diff
merge_request_diffs.reload
new_diff_refs = self.diff_refs
update_diff_notes_positions(
......
......@@ -291,7 +291,7 @@ describe MergeRequest, models: true do
end
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
end
......@@ -655,7 +655,7 @@ describe MergeRequest, models: true do
let(:commit) { subject.project.commit(sample_commit.id) }
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
end
......@@ -669,7 +669,6 @@ describe MergeRequest, models: true do
# Update merge_request_diff so that #diff_refs will return commit.diff_refs
allow(subject).to receive(:create_merge_request_diff) do
subject.merge_request_diffs.create(
importing: true,
base_commit_sha: commit.parent_id,
start_commit_sha: commit.parent_id,
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