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
Jérome Perrin
gitlab-ce
Commits
f9492554
Commit
f9492554
authored
Feb 12, 2018
by
Micaël Bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix specs
parent
1883c596
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
+18
-13
lib/gitlab/git/commit.rb
lib/gitlab/git/commit.rb
+8
-0
spec/workers/process_commit_worker_spec.rb
spec/workers/process_commit_worker_spec.rb
+10
-13
No files found.
lib/gitlab/git/commit.rb
View file @
f9492554
...
...
@@ -471,6 +471,14 @@ module Gitlab
private
def
parent_ids
=
(
shas
)
@parent_ids
=
case
shas
when
String
then
JSON
.
parse
(
shas
)
else
shas
end
end
def
init_from_hash
(
hash
)
raw_commit
=
hash
.
symbolize_keys
...
...
spec/workers/process_commit_worker_spec.rb
View file @
f9492554
...
...
@@ -74,11 +74,9 @@ describe ProcessCommitWorker do
describe
'#process_commit_message'
do
context
'when pushing to the default branch'
do
it
'closes issues that should be closed per the commit message'
do
allow
(
commit
).
to
receive
(
:safe_message
)
.
and_return
(
"Closes
#{
issue
.
to_reference
}
"
)
allow
(
commit
).
to
receive
(
:safe_message
).
and_return
(
"Closes
#{
issue
.
to_reference
}
"
)
expect
(
worker
).
to
receive
(
:close_issues
)
.
with
(
project
,
user
,
user
,
commit
,
[
issue
])
expect
(
worker
).
to
receive
(
:close_issues
).
with
(
project
,
user
,
user
,
commit
,
[
issue
])
worker
.
process_commit_message
(
project
,
commit
,
user
,
user
,
true
)
end
...
...
@@ -86,8 +84,7 @@ describe ProcessCommitWorker do
context
'when pushing to a non-default branch'
do
it
'does not close any issues'
do
allow
(
commit
).
to
receive
(
:safe_message
)
.
and_return
(
"Closes
#{
issue
.
to_reference
}
"
)
allow
(
commit
).
to
receive
(
:safe_message
).
and_return
(
"Closes
#{
issue
.
to_reference
}
"
)
expect
(
worker
).
not_to
receive
(
:close_issues
)
...
...
@@ -128,8 +125,7 @@ describe ProcessCommitWorker do
describe
'#update_issue_metrics'
do
it
'updates any existing issue metrics'
do
allow
(
commit
).
to
receive
(
:safe_message
)
.
and_return
(
"Closes
#{
issue
.
to_reference
}
"
)
allow
(
commit
).
to
receive
(
:safe_message
).
and_return
(
"Closes
#{
issue
.
to_reference
}
"
)
worker
.
update_issue_metrics
(
commit
,
user
)
...
...
@@ -139,10 +135,10 @@ describe ProcessCommitWorker do
end
it
"doesn't execute any queries with false conditions"
do
allow
(
commit
).
to
receive
(
:safe_message
)
.
and_return
(
"Lorem Ipsum"
)
allow
(
commit
).
to
receive
(
:safe_message
).
and_return
(
"Lorem Ipsum"
)
expect
{
worker
.
update_issue_metrics
(
commit
,
user
)
}.
not_to
make_queries_matching
(
/WHERE (?:1=0|0=1)/
)
expect
{
worker
.
update_issue_metrics
(
commit
,
user
)
}
.
not_to
make_queries_matching
(
/WHERE (?:1=0|0=1)/
)
end
end
...
...
@@ -154,8 +150,9 @@ describe ProcessCommitWorker do
end
it
'parses date strings into Time instances'
do
commit
=
worker
.
build_commit
(
project
,
id:
'123'
,
authored_date:
Time
.
now
.
to_s
)
commit
=
worker
.
build_commit
(
project
,
id:
'123'
,
authored_date:
Time
.
now
.
to_s
)
expect
(
commit
.
authored_date
).
to
be_an_instance_of
(
Time
)
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