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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
789aef7f
Commit
789aef7f
authored
Feb 15, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle nil commits in Gitlab::PushDataBuilder.build
Closes #13469
parent
c29517aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
9 deletions
+14
-9
lib/gitlab/push_data_builder.rb
lib/gitlab/push_data_builder.rb
+2
-0
spec/lib/gitlab/push_data_builder_spec.rb
spec/lib/gitlab/push_data_builder_spec.rb
+12
-9
No files found.
lib/gitlab/push_data_builder.rb
View file @
789aef7f
...
@@ -22,6 +22,8 @@ module Gitlab
...
@@ -22,6 +22,8 @@ module Gitlab
# }
# }
#
#
def
build
(
project
,
user
,
oldrev
,
newrev
,
ref
,
commits
=
[],
message
=
nil
)
def
build
(
project
,
user
,
oldrev
,
newrev
,
ref
,
commits
=
[],
message
=
nil
)
commits
=
Array
(
commits
)
# Total commits count
# Total commits count
commits_count
=
commits
.
size
commits_count
=
commits
.
size
...
...
spec/lib/gitlab/push_data_builder_spec.rb
View file @
789aef7f
require
'spec_helper'
require
'spec_helper'
describe
'Gitlab::PushDataBuilder'
,
lib:
true
do
describe
Gitlab
::
PushDataBuilder
,
lib:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
describe
:build_sample
do
describe
'.build_sample'
do
let
(
:data
)
{
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
}
let
(
:data
)
{
described_class
.
build_sample
(
project
,
user
)
}
it
{
expect
(
data
).
to
be_a
(
Hash
)
}
it
{
expect
(
data
).
to
be_a
(
Hash
)
}
it
{
expect
(
data
[
:before
]).
to
eq
(
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
)
}
it
{
expect
(
data
[
:before
]).
to
eq
(
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
)
}
...
@@ -22,13 +22,11 @@ describe 'Gitlab::PushDataBuilder', lib: true do
...
@@ -22,13 +22,11 @@ describe 'Gitlab::PushDataBuilder', lib: true do
it
{
expect
(
data
[
:commits
].
first
[
:removed
]).
to
eq
([])
}
it
{
expect
(
data
[
:commits
].
first
[
:removed
]).
to
eq
([])
}
end
end
describe
:build
do
describe
'.build'
do
let
(
:data
)
do
let
(
:data
)
do
Gitlab
::
PushDataBuilder
.
build
(
project
,
described_class
.
build
(
project
,
user
,
Gitlab
::
Git
::
BLANK_SHA
,
user
,
'8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b'
,
Gitlab
::
Git
::
BLANK_SHA
,
'refs/tags/v1.1.0'
)
'8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b'
,
'refs/tags/v1.1.0'
)
end
end
it
{
expect
(
data
).
to
be_a
(
Hash
)
}
it
{
expect
(
data
).
to
be_a
(
Hash
)
}
...
@@ -38,5 +36,10 @@ describe 'Gitlab::PushDataBuilder', lib: true do
...
@@ -38,5 +36,10 @@ describe 'Gitlab::PushDataBuilder', lib: true do
it
{
expect
(
data
[
:ref
]).
to
eq
(
'refs/tags/v1.1.0'
)
}
it
{
expect
(
data
[
:ref
]).
to
eq
(
'refs/tags/v1.1.0'
)
}
it
{
expect
(
data
[
:commits
]).
to
be_empty
}
it
{
expect
(
data
[
:commits
]).
to
be_empty
}
it
{
expect
(
data
[
:total_commits_count
]).
to
be_zero
}
it
{
expect
(
data
[
:total_commits_count
]).
to
be_zero
}
it
'does not raise an error when given nil commits'
do
expect
{
described_class
.
build
(
spy
,
spy
,
spy
,
spy
,
spy
,
nil
)
}.
not_to
raise_error
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