Skip to content
Snippets Groups Projects
Commit b0a02384 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Reload merge request association reload when update code

parent 8e031ce3
No related branches found
No related tags found
No related merge requests found
Loading
@@ -246,13 +246,7 @@ class MergeRequest < ActiveRecord::Base
Loading
@@ -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
Loading
@@ -306,6 +300,7 @@ class MergeRequest < ActiveRecord::Base
Loading
@@ -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(
Loading
Loading
Loading
@@ -291,7 +291,7 @@ describe MergeRequest, models: true do
Loading
@@ -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
Loading
@@ -655,7 +655,7 @@ describe MergeRequest, models: true do
Loading
@@ -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
   
Loading
@@ -669,7 +669,6 @@ describe MergeRequest, models: true do
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment