Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
cdcc11d4
Commit
cdcc11d4
authored
Sep 29, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve tests for merge request diff model
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
afe28b7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
16 deletions
+26
-16
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+1
-1
spec/models/merge_request_diff_spec.rb
spec/models/merge_request_diff_spec.rb
+25
-15
No files found.
app/models/merge_request_diff.rb
View file @
cdcc11d4
...
@@ -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
...
...
spec/models/merge_request_diff_spec.rb
View file @
cdcc11d4
...
@@ -74,27 +74,37 @@ describe MergeRequestDiff, models: true do
...
@@ -74,27 +74,37 @@ 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
it
'returns all commits SHA'
do
it
'returns all commits SHA'
do
commits_sha
=
subject
.
commits_sha
commits_sha
=
subject
.
commits_sha
expect
(
commits_sha
).
to
eq
(
subject
.
commits
.
map
(
&
:sha
))
expect
(
commits_sha
).
to
eq
(
subject
.
commits
.
map
(
&
:sha
))
end
end
end
end
context
'when commits were loaded'
do
context
'when commits were loaded'
do
before
do
before
do
subject
.
commits
subject
.
commits
end
it_behaves_like
'returning all commits SHA'
end
end
context
'when commits were not loaded'
do
it_behaves_like
'returning all commits SHA'
it_behaves_like
'returning all commits SHA'
end
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
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment