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
16e1076e
Commit
16e1076e
authored
Apr 03, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests.
parent
e33ddfeb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
48 deletions
+54
-48
closing_issue_extractor_spec.rb
spec/lib/gitlab/closing_issue_extractor_spec.rb
+32
-30
reference_extractor_spec.rb
spec/lib/gitlab/reference_extractor_spec.rb
+22
-18
No files found.
spec/lib/gitlab/closing_issue_extractor_spec.rb
View file @
16e1076e
...
...
@@ -5,126 +5,128 @@ describe Gitlab::ClosingIssueExtractor do
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:iid1
)
{
issue
.
iid
}
describe
:closed_by_message_in_project
do
subject
{
described_class
.
new
(
project
,
project
.
creator
)
}
describe
"#closed_by_message"
do
context
'with a single reference'
do
it
do
message
=
"Awesome commit (Closes #
#{
iid1
}
)"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Awesome commit (closes #
#{
iid1
}
)"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Closed #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"closed #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Closing #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"closing #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Close #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"close #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Awesome commit (Fixes #
#{
iid1
}
)"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Awesome commit (fixes #
#{
iid1
}
)"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Fixed #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"fixed #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Fixing #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"fixing #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Fix #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"fix #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Awesome commit (Resolves #
#{
iid1
}
)"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Awesome commit (resolves #
#{
iid1
}
)"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Resolved #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"resolved #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Resolving #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"resolving #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"Resolve #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
it
do
message
=
"resolve #
#{
iid1
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
...
...
@@ -137,28 +139,28 @@ describe Gitlab::ClosingIssueExtractor do
it
'fetches issues in single line message'
do
message
=
"Closes #
#{
iid1
}
and fix #
#{
iid2
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
,
other_issue
])
end
it
'fetches comma-separated issues references in single line message'
do
message
=
"Closes #
#{
iid1
}
, closes #
#{
iid2
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
,
other_issue
])
end
it
'fetches comma-separated issues numbers in single line message'
do
message
=
"Closes #
#{
iid1
}
, #
#{
iid2
}
and #
#{
iid3
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
,
other_issue
,
third_issue
])
end
it
'fetches issues in multi-line message'
do
message
=
"Awesome commit (closes #
#{
iid1
}
)
\n
Also fixes #
#{
iid2
}
"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
,
other_issue
])
end
...
...
@@ -166,7 +168,7 @@ describe Gitlab::ClosingIssueExtractor do
message
=
"Awesome commit (closes #
#{
iid1
}
)
\n
"
\
"Also fixing issues #
#{
iid2
}
, #
#{
iid3
}
and #4"
expect
(
subject
.
closed_by_message
_in_project
(
message
,
project
)).
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
,
other_issue
,
third_issue
])
end
end
...
...
spec/lib/gitlab/reference_extractor_spec.rb
View file @
16e1076e
...
...
@@ -2,48 +2,48 @@ require 'spec_helper'
describe
Gitlab
::
ReferenceExtractor
do
let
(
:project
)
{
create
(
:project
)
}
subject
{
Gitlab
::
ReferenceExtractor
.
new
(
project
)
}
subject
{
Gitlab
::
ReferenceExtractor
.
new
(
project
,
project
.
creator
)
}
it
'extracts username references'
do
subject
.
analyze
(
'this contains a @user reference'
)
expect
(
subject
.
users
).
to
eq
([{
project:
project
,
id:
'user'
}
])
expect
(
subject
.
references
[
:user
]).
to
eq
([[
project
,
'user'
]
])
end
it
'extracts issue references'
do
subject
.
analyze
(
'this one talks about issue #1234'
)
expect
(
subject
.
issues
).
to
eq
([{
project:
project
,
id:
'1234'
}
])
expect
(
subject
.
references
[
:issue
]).
to
eq
([[
project
,
'1234'
]
])
end
it
'extracts JIRA issue references'
do
subject
.
analyze
(
'this one talks about issue JIRA-1234'
)
expect
(
subject
.
issues
).
to
eq
([{
project:
project
,
id:
'JIRA-1234'
}
])
expect
(
subject
.
references
[
:issue
]).
to
eq
([[
project
,
'JIRA-1234'
]
])
end
it
'extracts merge request references'
do
subject
.
analyze
(
"and here's !43, a merge request"
)
expect
(
subject
.
merge_requests
).
to
eq
([{
project:
project
,
id:
'43'
}
])
expect
(
subject
.
references
[
:merge_request
]).
to
eq
([[
project
,
'43'
]
])
end
it
'extracts snippet ids'
do
subject
.
analyze
(
'snippets like $12 get extracted as well'
)
expect
(
subject
.
snippets
).
to
eq
([{
project:
project
,
id:
'12'
}
])
expect
(
subject
.
references
[
:snippet
]).
to
eq
([[
project
,
'12'
]
])
end
it
'extracts commit shas'
do
subject
.
analyze
(
'commit shas 98cf0ae3 are pulled out as Strings'
)
expect
(
subject
.
commits
).
to
eq
([{
project:
project
,
id:
'98cf0ae3'
}
])
expect
(
subject
.
references
[
:commit
]).
to
eq
([[
project
,
'98cf0ae3'
]
])
end
it
'extracts commit ranges'
do
subject
.
analyze
(
'here you go, a commit range: 98cf0ae3...98cf0ae4'
)
expect
(
subject
.
commit_ranges
).
to
eq
([{
project:
project
,
id:
'98cf0ae3...98cf0ae4'
}
])
expect
(
subject
.
references
[
:commit_range
]).
to
eq
([[
project
,
'98cf0ae3...98cf0ae4'
]
])
end
it
'extracts multiple references and preserves their order'
do
subject
.
analyze
(
'@me and @you both care about this'
)
expect
(
subject
.
users
).
to
eq
([
{
project:
project
,
id:
'me'
}
,
{
project:
project
,
id:
'you'
}
expect
(
subject
.
references
[
:user
]
).
to
eq
([
[
project
,
'me'
]
,
[
project
,
'you'
]
])
end
...
...
@@ -70,7 +70,7 @@ describe Gitlab::ReferenceExtractor do
it
'extracts issue references for invalid code blocks'
do
subject
.
analyze
(
'test: ```this one talks about issue #1234```'
)
expect
(
subject
.
issues
).
to
eq
([{
project:
project
,
id:
'1234'
}
])
expect
(
subject
.
references
[
:issue
]).
to
eq
([[
project
,
'1234'
]
])
end
it
'handles all possible kinds of references'
do
...
...
@@ -78,16 +78,16 @@ describe Gitlab::ReferenceExtractor do
expect
(
subject
).
to
respond_to
(
*
accessors
)
end
it
'accesses valid user objects
on the project team
'
do
it
'accesses valid user objects'
do
@u_foo
=
create
(
:user
,
username:
'foo'
)
@u_bar
=
create
(
:user
,
username:
'bar'
)
create
(
:user
,
username:
'offteam'
)
@u_offteam
=
create
(
:user
,
username:
'offteam'
)
project
.
team
<<
[
@u_foo
,
:reporter
]
project
.
team
<<
[
@u_bar
,
:guest
]
subject
.
analyze
(
'@foo, @baduser, @bar, and @offteam'
)
expect
(
subject
.
users
).
to
eq
([
@u_foo
,
@u_bar
])
expect
(
subject
.
users
).
to
eq
([
@u_foo
,
@u_bar
,
@u_offteam
])
end
it
'accesses valid issue objects'
do
...
...
@@ -139,11 +139,15 @@ describe Gitlab::ReferenceExtractor do
end
context
'with a project with an underscore'
do
let
(
:project
)
{
create
(
:project
,
path:
'test_project'
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:other_project
)
{
create
(
:project
,
path:
'test_project'
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
other_project
)
}
before
do
other_project
.
team
<<
[
project
.
creator
,
:developer
]
end
it
'handles project issue references'
do
subject
.
analyze
(
"this refers issue
#{
project
.
path_with_namespace
}
#
#{
issue
.
iid
}
"
)
subject
.
analyze
(
"this refers issue
#{
other_
project
.
path_with_namespace
}
#
#{
issue
.
iid
}
"
)
extracted
=
subject
.
issues
expect
(
extracted
.
size
).
to
eq
(
1
)
expect
(
extracted
).
to
eq
([
issue
])
...
...
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