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
a97ff8aa
Commit
a97ff8aa
authored
Sep 20, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a factory for `Gitaly::GitCommit`s
parent
171714c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
27 deletions
+31
-27
spec/factories/gitaly/commit.rb
spec/factories/gitaly/commit.rb
+17
-0
spec/factories/gitaly/commit_author.rb
spec/factories/gitaly/commit_author.rb
+9
-0
spec/lib/gitlab/git/commit_spec.rb
spec/lib/gitlab/git/commit_spec.rb
+5
-27
No files found.
spec/factories/gitaly/commit.rb
0 → 100644
View file @
a97ff8aa
FactoryGirl
.
define
do
sequence
(
:gitaly_commit_id
)
{
Digest
::
SHA1
.
hexdigest
(
Time
.
now
.
to_f
.
to_s
)
}
factory
:gitaly_commit
,
class:
Gitaly
::
GitCommit
do
skip_create
id
{
generate
(
:gitaly_commit_id
)
}
parent_ids
do
ids
=
[
generate
(
:gitaly_commit_id
),
generate
(
:gitaly_commit_id
)]
Google
::
Protobuf
::
RepeatedField
.
new
(
:string
,
ids
)
end
subject
{
"My commit"
}
body
{
subject
+
"
\n
My body"
}
author
{
build
(
:gitaly_commit_author
)
}
committer
{
build
(
:gitaly_commit_author
)
}
end
end
spec/factories/gitaly/commit_author.rb
0 → 100644
View file @
a97ff8aa
FactoryGirl
.
define
do
factory
:gitaly_commit_author
,
class:
Gitaly
::
CommitAuthor
do
skip_create
name
{
generate
(
:name
)
}
email
{
generate
(
:email
)
}
date
{
Google
::
Protobuf
::
Timestamp
.
new
(
seconds:
Time
.
now
.
to_i
)
}
end
end
spec/lib/gitlab/git/commit_spec.rb
View file @
a97ff8aa
...
...
@@ -65,34 +65,12 @@ describe Gitlab::Git::Commit, seed_helper: true do
end
describe
"Commit info from gitaly commit"
do
let
(
:id
)
{
'f00'
}
let
(
:parent_ids
)
{
%w(b45 b46)
}
let
(
:subject
)
{
"My commit"
.
force_encoding
(
'ASCII-8BIT'
)
}
let
(
:body
)
{
subject
+
"My body"
.
force_encoding
(
'ASCII-8BIT'
)
}
let
(
:committer
)
do
Gitaly
::
CommitAuthor
.
new
(
name:
generate
(
:name
),
email:
generate
(
:email
),
date:
Google
::
Protobuf
::
Timestamp
.
new
(
seconds:
123
)
)
end
let
(
:author
)
do
Gitaly
::
CommitAuthor
.
new
(
name:
generate
(
:name
),
email:
generate
(
:email
),
date:
Google
::
Protobuf
::
Timestamp
.
new
(
seconds:
456
)
)
end
let
(
:gitaly_commit
)
do
Gitaly
::
GitCommit
.
new
(
id:
id
,
subject:
subject
,
body:
body
,
author:
author
,
committer:
committer
,
parent_ids:
parent_ids
)
end
let
(
:gitaly_commit
)
{
build
(
:gitaly_commit
,
subject:
subject
,
body:
body
)
}
let
(
:id
)
{
gitaly_commit
.
id
}
let
(
:committer
)
{
gitaly_commit
.
committer
}
let
(
:author
)
{
gitaly_commit
.
author
}
let
(
:commit
)
{
described_class
.
new
(
repository
,
gitaly_commit
)
}
it
{
expect
(
commit
.
short_id
).
to
eq
(
id
[
0
..
10
])
}
...
...
@@ -104,7 +82,7 @@ describe Gitlab::Git::Commit, seed_helper: true do
it
{
expect
(
commit
.
author_name
).
to
eq
(
author
.
name
)
}
it
{
expect
(
commit
.
committer_name
).
to
eq
(
committer
.
name
)
}
it
{
expect
(
commit
.
committer_email
).
to
eq
(
committer
.
email
)
}
it
{
expect
(
commit
.
parent_ids
).
to
eq
(
parent_ids
)
}
it
{
expect
(
commit
.
parent_ids
).
to
eq
(
gitaly_commit
.
parent_ids
)
}
context
'no body'
do
let
(
:body
)
{
""
.
force_encoding
(
'ASCII-8BIT'
)
}
...
...
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