summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/merge_request_diff.rb2
-rw-r--r--spec/models/merge_request_diff_spec.rb40
2 files changed, 26 insertions, 16 deletions
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb
index 0ea9e892be2..6ad2201573d 100644
--- a/app/models/merge_request_diff.rb
+++ b/app/models/merge_request_diff.rb
@@ -169,7 +169,7 @@ class MergeRequestDiff < ActiveRecord::Base
def compare_with(sha, straight = true)
# When compare merge request versions we want diff A..B instead of A...B
- # so we handle cases when user squash and rebase commits in one of versions.
+ # so we handle cases when user does squash and rebase of the commits between versions.
# For this reason we set straight to true by default.
CompareService.new.execute(project, head_commit_sha, project, sha, straight)
end
diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb
index f27de0948ee..69b8afd22a3 100644
--- a/spec/models/merge_request_diff_spec.rb
+++ b/spec/models/merge_request_diff_spec.rb
@@ -74,27 +74,37 @@ describe MergeRequestDiff, models: true do
end
end
end
+ end
- describe '#commits_sha' do
- shared_examples 'returning all commits SHA' do
- it 'returns all commits SHA' do
- commits_sha = subject.commits_sha
+ describe '#commits_sha' do
+ shared_examples 'returning all commits SHA' do
+ it 'returns all commits SHA' do
+ commits_sha = subject.commits_sha
- expect(commits_sha).to eq(subject.commits.map(&:sha))
- end
+ expect(commits_sha).to eq(subject.commits.map(&:sha))
end
+ end
- context 'when commits were loaded' do
- before do
- subject.commits
- end
-
- it_behaves_like 'returning all commits SHA'
+ context 'when commits were loaded' do
+ before do
+ subject.commits
end
- context 'when commits were not loaded' do
- it_behaves_like 'returning all commits SHA'
- end
+ it_behaves_like 'returning all commits SHA'
+ end
+
+ context 'when commits were not loaded' do
+ it_behaves_like 'returning all commits SHA'
+ end
+ end
+
+ describe '#compare_with' do
+ subject { create(:merge_request).merge_request_diff }
+
+ it 'delegates compare to the service' do
+ expect(CompareService).to receive(:new).and_call_original
+
+ subject.compare_with('ae73cb07c9eeaf35924a10f713b364d32b2dd34f')
end
end
end