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
3c1dca03
Commit
3c1dca03
authored
Jul 28, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more tests to merge_request_diff and improve initialize
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
0e974b52
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
merge_request.rb
app/models/merge_request.rb
+3
-1
merge_request_diff.rb
app/models/merge_request_diff.rb
+1
-3
merge_request_diff_spec.rb
spec/models/merge_request_diff_spec.rb
+17
-0
No files found.
app/models/merge_request.rb
View file @
3c1dca03
...
...
@@ -246,7 +246,9 @@ class MergeRequest < ActiveRecord::Base
end
def
diff_refs
merge_request_diff
.
diff_refs
if
merge_request_diff
merge_request_diff
.
diff_refs
end
end
def
validate_branches
...
...
app/models/merge_request_diff.rb
View file @
3c1dca03
...
...
@@ -35,7 +35,7 @@ class MergeRequestDiff < ActiveRecord::Base
# have those variables in the database so we try to initialize it
def
initialize_commits_sha
self
.
start_commit_sha
||=
merge_request
.
target_branch_sha
self
.
head_commit_sha
||=
last_commit
.
try
(
:sha
)
||
merge_request
.
source_branch_sha
self
.
head_commit_sha
||=
persisted?
?
last_commit
.
sha
:
merge_request
.
source_branch_sha
self
.
base_commit_sha
||=
find_base_sha
end
...
...
@@ -191,9 +191,7 @@ class MergeRequestDiff < ActiveRecord::Base
end
new_attributes
[
:st_diffs
]
=
new_diffs
update_columns_serialized
(
new_attributes
)
keep_around_commits
end
...
...
spec/models/merge_request_diff_spec.rb
View file @
3c1dca03
require
'spec_helper'
describe
MergeRequestDiff
,
models:
true
do
describe
'initialize new object'
do
subject
{
build
(
:merge_request
).
merge_request_diffs
.
build
}
it
{
expect
(
subject
).
to
be_valid
}
it
{
expect
(
subject
.
head_commit_sha
).
to
eq
(
'5937ac0a7beb003549fc5fd26fc247adbce4a52e'
)
}
it
{
expect
(
subject
.
base_commit_sha
).
to
eq
(
'ae73cb07c9eeaf35924a10f713b364d32b2dd34f'
)
}
it
{
expect
(
subject
.
start_commit_sha
).
to
eq
(
'0b4bc9a49b562e85de7cc9e834518ea6828729b9'
)
}
end
describe
'create new record'
do
subject
{
create
(
:merge_request
)
}
it
{
expect
(
subject
).
to
be_valid
}
it
{
expect
(
subject
.
commits
.
count
).
to
eq
(
5
)
}
it
{
expect
(
subject
.
diffs
.
count
).
to
eq
(
8
)
}
end
describe
'#diffs'
do
let
(
:mr
)
{
create
(
:merge_request
,
:with_diffs
)
}
let
(
:mr_diff
)
{
mr
.
merge_request_diff
}
...
...
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