Commit cdcc11d4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve tests for merge request diff model

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent afe28b7b
...@@ -169,7 +169,7 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -169,7 +169,7 @@ class MergeRequestDiff < ActiveRecord::Base
def compare_with(sha, straight = true) def compare_with(sha, straight = true)
# When compare merge request versions we want diff A..B instead of A...B # 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. # For this reason we set straight to true by default.
CompareService.new.execute(project, head_commit_sha, project, sha, straight) CompareService.new.execute(project, head_commit_sha, project, sha, straight)
end end
......
...@@ -74,6 +74,7 @@ describe MergeRequestDiff, models: true do ...@@ -74,6 +74,7 @@ describe MergeRequestDiff, models: true do
end end
end end
end end
end
describe '#commits_sha' do describe '#commits_sha' do
shared_examples 'returning all commits SHA' do shared_examples 'returning all commits SHA' do
...@@ -96,5 +97,14 @@ describe MergeRequestDiff, models: true do ...@@ -96,5 +97,14 @@ describe MergeRequestDiff, models: true do
it_behaves_like 'returning all commits SHA' it_behaves_like 'returning all commits SHA'
end end
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
end end
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