BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
631f59d4
Commit
631f59d4
authored
Aug 03, 2016
by
Paco Guzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change the API on the merge_request_diff model from diffs -> raw_diffs
parent
6a928360
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
14 deletions
+14
-14
merge_request.rb
app/models/merge_request.rb
+1
-1
merge_request_diff.rb
app/models/merge_request_diff.rb
+5
-5
merge_request_diff_spec.rb
spec/models/merge_request_diff_spec.rb
+6
-6
merge_request_spec.rb
spec/models/merge_request_spec.rb
+2
-2
No files found.
app/models/merge_request.rb
View file @
631f59d4
...
...
@@ -165,7 +165,7 @@ class MergeRequest < ActiveRecord::Base
end
def
raw_diffs
(
*
args
)
merge_request_diff
?
merge_request_diff
.
diffs
(
*
args
)
:
compare
.
raw_diffs
(
*
args
)
merge_request_diff
?
merge_request_diff
.
raw_
diffs
(
*
args
)
:
compare
.
raw_diffs
(
*
args
)
end
def
diffs
(
diff_options
=
nil
)
...
...
app/models/merge_request_diff.rb
View file @
631f59d4
...
...
@@ -33,12 +33,12 @@ class MergeRequestDiff < ActiveRecord::Base
end
def
size
real_size
.
presence
||
diffs
.
size
real_size
.
presence
||
raw_
diffs
.
size
end
def
diffs
(
options
=
{})
def
raw_
diffs
(
options
=
{})
if
options
[
:ignore_whitespace_change
]
@diffs_no_whitespace
||=
begin
@
raw_
diffs_no_whitespace
||=
begin
compare
=
Gitlab
::
Git
::
Compare
.
new
(
repository
.
raw_repository
,
self
.
start_commit_sha
||
self
.
target_branch_sha
,
...
...
@@ -47,8 +47,8 @@ class MergeRequestDiff < ActiveRecord::Base
compare
.
diffs
(
options
)
end
else
@diffs
||=
{}
@diffs
[
options
]
||=
load_diffs
(
st_diffs
,
options
)
@
raw_
diffs
||=
{}
@
raw_
diffs
[
options
]
||=
load_diffs
(
st_diffs
,
options
)
end
end
...
...
spec/models/merge_request_diff_spec.rb
View file @
631f59d4
...
...
@@ -10,7 +10,7 @@ describe MergeRequestDiff, models: true do
expect
(
mr_diff
).
not_to
receive
(
:load_diffs
)
expect
(
Gitlab
::
Git
::
Compare
).
to
receive
(
:new
).
and_call_original
mr_diff
.
diffs
(
ignore_whitespace_change:
true
)
mr_diff
.
raw_
diffs
(
ignore_whitespace_change:
true
)
end
end
...
...
@@ -18,19 +18,19 @@ describe MergeRequestDiff, models: true do
before
{
mr_diff
.
update_attributes
(
st_diffs:
''
)
}
it
'returns an empty DiffCollection'
do
expect
(
mr_diff
.
diffs
).
to
be_a
(
Gitlab
::
Git
::
DiffCollection
)
expect
(
mr_diff
.
diffs
).
to
be_empty
expect
(
mr_diff
.
raw_
diffs
).
to
be_a
(
Gitlab
::
Git
::
DiffCollection
)
expect
(
mr_diff
.
raw_
diffs
).
to
be_empty
end
end
context
'when the raw diffs exist'
do
it
'returns the diffs'
do
expect
(
mr_diff
.
diffs
).
to
be_a
(
Gitlab
::
Git
::
DiffCollection
)
expect
(
mr_diff
.
diffs
).
not_to
be_empty
expect
(
mr_diff
.
raw_
diffs
).
to
be_a
(
Gitlab
::
Git
::
DiffCollection
)
expect
(
mr_diff
.
raw_
diffs
).
not_to
be_empty
end
context
'when the :paths option is set'
do
let
(
:diffs
)
{
mr_diff
.
diffs
(
paths:
[
'files/ruby/popen.rb'
,
'files/ruby/popen.rb'
])
}
let
(
:diffs
)
{
mr_diff
.
raw_
diffs
(
paths:
[
'files/ruby/popen.rb'
,
'files/ruby/popen.rb'
])
}
it
'only returns diffs that match the (old path, new path) given'
do
expect
(
diffs
.
map
(
&
:new_path
)).
to
contain_exactly
(
'files/ruby/popen.rb'
)
...
...
spec/models/merge_request_spec.rb
View file @
631f59d4
...
...
@@ -136,7 +136,7 @@ describe MergeRequest, models: true do
it
'delegates to the MR diffs'
do
merge_request
.
merge_request_diff
=
MergeRequestDiff
.
new
expect
(
merge_request
.
merge_request_diff
).
to
receive
(
:diffs
).
with
(
options
)
expect
(
merge_request
.
merge_request_diff
).
to
receive
(
:
raw_
diffs
).
with
(
options
)
merge_request
.
raw_diffs
(
options
)
end
...
...
@@ -161,7 +161,7 @@ describe MergeRequest, models: true do
it
'delegates to the MR diffs'
do
merge_request
.
merge_request_diff
=
MergeRequestDiff
.
new
expect
(
merge_request
.
merge_request_diff
).
to
receive
(
:diffs
).
with
(
hash_including
(
options
))
expect
(
merge_request
.
merge_request_diff
).
to
receive
(
:
raw_
diffs
).
with
(
hash_including
(
options
))
merge_request
.
diffs
(
options
)
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