Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
5a9c5520
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5a9c5520
编写于
5月 21, 2015
作者:
R
Robert Speicher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make use of to_reference in more specs
上级
68f74aa8
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
76 addition
and
73 deletion
+76
-73
lib/gitlab/closing_issue_extractor.rb
lib/gitlab/closing_issue_extractor.rb
+1
-1
lib/gitlab/markdown/external_issue_reference_filter.rb
lib/gitlab/markdown/external_issue_reference_filter.rb
+1
-1
lib/gitlab/markdown/issue_reference_filter.rb
lib/gitlab/markdown/issue_reference_filter.rb
+1
-1
lib/gitlab/markdown/merge_request_reference_filter.rb
lib/gitlab/markdown/merge_request_reference_filter.rb
+1
-1
lib/gitlab/markdown/snippet_reference_filter.rb
lib/gitlab/markdown/snippet_reference_filter.rb
+1
-1
lib/gitlab/markdown/user_reference_filter.rb
lib/gitlab/markdown/user_reference_filter.rb
+6
-3
spec/features/gitlab_flavored_markdown_spec.rb
spec/features/gitlab_flavored_markdown_spec.rb
+17
-17
spec/helpers/gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+5
-5
spec/lib/gitlab/closing_issue_extractor_spec.rb
spec/lib/gitlab/closing_issue_extractor_spec.rb
+35
-35
spec/lib/gitlab/reference_extractor_spec.rb
spec/lib/gitlab/reference_extractor_spec.rb
+2
-2
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+1
-1
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+5
-5
未找到文件。
lib/gitlab/closing_issue_extractor.rb
浏览文件 @
5a9c5520
...
@@ -8,7 +8,7 @@ module Gitlab
...
@@ -8,7 +8,7 @@ module Gitlab
def
closed_by_message
(
message
)
def
closed_by_message
(
message
)
return
[]
if
message
.
nil?
return
[]
if
message
.
nil?
closing_statements
=
message
.
scan
(
ISSUE_CLOSING_REGEX
).
closing_statements
=
message
.
scan
(
ISSUE_CLOSING_REGEX
).
map
{
|
ref
|
ref
[
0
]
}.
join
(
" "
)
map
{
|
ref
|
ref
[
0
]
}.
join
(
" "
)
...
...
lib/gitlab/markdown/external_issue_reference_filter.rb
浏览文件 @
5a9c5520
...
@@ -48,7 +48,7 @@ module Gitlab
...
@@ -48,7 +48,7 @@ module Gitlab
%(<a href="#{url}"
%(<a href="#{url}"
title="#{title}"
title="#{title}"
class="#{klass}">#{
issue
}</a>)
class="#{klass}">#{
match
}</a>)
end
end
end
end
...
...
lib/gitlab/markdown/issue_reference_filter.rb
浏览文件 @
5a9c5520
...
@@ -52,7 +52,7 @@ module Gitlab
...
@@ -52,7 +52,7 @@ module Gitlab
%(<a href="#{url}"
%(<a href="#{url}"
title="#{title}"
title="#{title}"
class="#{klass}">#{
project_ref}##{id
}</a>)
class="#{klass}">#{
match
}</a>)
else
else
match
match
end
end
...
...
lib/gitlab/markdown/merge_request_reference_filter.rb
浏览文件 @
5a9c5520
...
@@ -52,7 +52,7 @@ module Gitlab
...
@@ -52,7 +52,7 @@ module Gitlab
%(<a href="#{url}"
%(<a href="#{url}"
title="#{title}"
title="#{title}"
class="#{klass}">#{
project_ref}!#{id
}</a>)
class="#{klass}">#{
match
}</a>)
else
else
match
match
end
end
...
...
lib/gitlab/markdown/snippet_reference_filter.rb
浏览文件 @
5a9c5520
...
@@ -52,7 +52,7 @@ module Gitlab
...
@@ -52,7 +52,7 @@ module Gitlab
%(<a href="#{url}"
%(<a href="#{url}"
title="#{title}"
title="#{title}"
class="#{klass}">#{
project_ref}$#{id
}</a>)
class="#{klass}">#{
match
}</a>)
else
else
match
match
end
end
...
...
lib/gitlab/markdown/user_reference_filter.rb
浏览文件 @
5a9c5520
...
@@ -65,7 +65,8 @@ module Gitlab
...
@@ -65,7 +65,8 @@ module Gitlab
url
=
urls
.
namespace_project_url
(
project
.
namespace
,
project
,
url
=
urls
.
namespace_project_url
(
project
.
namespace
,
project
,
only_path:
context
[
:only_path
])
only_path:
context
[
:only_path
])
%(<a href="#{url}" class="#{link_class}">@all</a>)
text
=
User
.
reference_prefix
+
'all'
%(<a href="#{url}" class="#{link_class}">#{text}</a>)
end
end
def
link_to_namespace
(
namespace
)
def
link_to_namespace
(
namespace
)
...
@@ -83,7 +84,8 @@ module Gitlab
...
@@ -83,7 +84,8 @@ module Gitlab
url
=
urls
.
group_url
(
group
,
only_path:
context
[
:only_path
])
url
=
urls
.
group_url
(
group
,
only_path:
context
[
:only_path
])
%(<a href="#{url}" class="#{link_class}">@#{group}</a>)
text
=
Group
.
reference_prefix
+
group
%(<a href="#{url}" class="#{link_class}">#{text}</a>)
end
end
def
link_to_user
(
user
,
namespace
)
def
link_to_user
(
user
,
namespace
)
...
@@ -91,7 +93,8 @@ module Gitlab
...
@@ -91,7 +93,8 @@ module Gitlab
url
=
urls
.
user_url
(
user
,
only_path:
context
[
:only_path
])
url
=
urls
.
user_url
(
user
,
only_path:
context
[
:only_path
])
%(<a href="#{url}" class="#{link_class}">@#{user}</a>)
text
=
User
.
reference_prefix
+
user
%(<a href="#{url}" class="#{link_class}">#{text}</a>)
end
end
def
user_can_reference_group?
(
group
)
def
user_can_reference_group?
(
group
)
...
...
spec/features/gitlab_flavored_markdown_spec.rb
浏览文件 @
5a9c5520
...
@@ -11,7 +11,7 @@ describe "GitLab Flavored Markdown", feature: true do
...
@@ -11,7 +11,7 @@ describe "GitLab Flavored Markdown", feature: true do
end
end
before
do
before
do
Commit
.
any_instance
.
stub
(
title:
"fix #
#{
issue
.
iid
}
\n\n
ask @
#{
fred
.
usernam
e
}
for details"
)
Commit
.
any_instance
.
stub
(
title:
"fix
#
{
issue
.
to_reference
}
\n\n
ask
#{
fred
.
to_referenc
e
}
for details"
)
end
end
let
(
:commit
)
{
project
.
commit
}
let
(
:commit
)
{
project
.
commit
}
...
@@ -25,25 +25,25 @@ describe "GitLab Flavored Markdown", feature: true do
...
@@ -25,25 +25,25 @@ describe "GitLab Flavored Markdown", feature: true do
it
"should render title in commits#index"
do
it
"should render title in commits#index"
do
visit
namespace_project_commits_path
(
project
.
namespace
,
project
,
'master'
,
limit:
1
)
visit
namespace_project_commits_path
(
project
.
namespace
,
project
,
'master'
,
limit:
1
)
expect
(
page
).
to
have_link
(
"#
#{
issue
.
iid
}
"
)
expect
(
page
).
to
have_link
(
issue
.
to_reference
)
end
end
it
"should render title in commits#show"
do
it
"should render title in commits#show"
do
visit
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
)
visit
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
)
expect
(
page
).
to
have_link
(
"#
#{
issue
.
iid
}
"
)
expect
(
page
).
to
have_link
(
issue
.
to_reference
)
end
end
it
"should render description in commits#show"
do
it
"should render description in commits#show"
do
visit
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
)
visit
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
)
expect
(
page
).
to
have_link
(
"@
#{
fred
.
username
}
"
)
expect
(
page
).
to
have_link
(
fred
.
to_reference
)
end
end
it
"should render title in repositories#branches"
do
it
"should render title in repositories#branches"
do
visit
namespace_project_branches_path
(
project
.
namespace
,
project
)
visit
namespace_project_branches_path
(
project
.
namespace
,
project
)
expect
(
page
).
to
have_link
(
"#
#{
issue
.
iid
}
"
)
expect
(
page
).
to
have_link
(
issue
.
to_reference
)
end
end
end
end
...
@@ -57,20 +57,20 @@ describe "GitLab Flavored Markdown", feature: true do
...
@@ -57,20 +57,20 @@ describe "GitLab Flavored Markdown", feature: true do
author:
@user
,
author:
@user
,
assignee:
@user
,
assignee:
@user
,
project:
project
,
project:
project
,
title:
"fix #
#{
@other_issue
.
iid
}
"
,
title:
"fix
#
{
@other_issue
.
to_reference
}
"
,
description:
"ask
@
#{
fred
.
usernam
e
}
for details"
)
description:
"ask
#{
fred
.
to_referenc
e
}
for details"
)
end
end
it
"should render subject in issues#index"
do
it
"should render subject in issues#index"
do
visit
namespace_project_issues_path
(
project
.
namespace
,
project
)
visit
namespace_project_issues_path
(
project
.
namespace
,
project
)
expect
(
page
).
to
have_link
(
"#
#{
@other_issue
.
iid
}
"
)
expect
(
page
).
to
have_link
(
@other_issue
.
to_reference
)
end
end
it
"should render subject in issues#show"
do
it
"should render subject in issues#show"
do
visit
namespace_project_issue_path
(
project
.
namespace
,
project
,
@issue
)
visit
namespace_project_issue_path
(
project
.
namespace
,
project
,
@issue
)
expect
(
page
).
to
have_link
(
"#
#{
@other_issue
.
iid
}
"
)
expect
(
page
).
to
have_link
(
@other_issue
.
to_reference
)
end
end
it
"should render details in issues#show"
do
it
"should render details in issues#show"
do
...
@@ -83,19 +83,19 @@ describe "GitLab Flavored Markdown", feature: true do
...
@@ -83,19 +83,19 @@ describe "GitLab Flavored Markdown", feature: true do
describe
"for merge requests"
do
describe
"for merge requests"
do
before
do
before
do
@merge_request
=
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
title:
"fix #
#{
issue
.
iid
}
"
)
@merge_request
=
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
title:
"fix
#
{
issue
.
to_reference
}
"
)
end
end
it
"should render title in merge_requests#index"
do
it
"should render title in merge_requests#index"
do
visit
namespace_project_merge_requests_path
(
project
.
namespace
,
project
)
visit
namespace_project_merge_requests_path
(
project
.
namespace
,
project
)
expect
(
page
).
to
have_link
(
"#
#{
issue
.
iid
}
"
)
expect
(
page
).
to
have_link
(
issue
.
to_reference
)
end
end
it
"should render title in merge_requests#show"
do
it
"should render title in merge_requests#show"
do
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
@merge_request
)
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
@merge_request
)
expect
(
page
).
to
have_link
(
"#
#{
issue
.
iid
}
"
)
expect
(
page
).
to
have_link
(
issue
.
to_reference
)
end
end
end
end
...
@@ -104,26 +104,26 @@ describe "GitLab Flavored Markdown", feature: true do
...
@@ -104,26 +104,26 @@ describe "GitLab Flavored Markdown", feature: true do
before
do
before
do
@milestone
=
create
(
:milestone
,
@milestone
=
create
(
:milestone
,
project:
project
,
project:
project
,
title:
"fix #
#{
issue
.
iid
}
"
,
title:
"fix
#
{
issue
.
to_reference
}
"
,
description:
"ask
@
#{
fred
.
usernam
e
}
for details"
)
description:
"ask
#{
fred
.
to_referenc
e
}
for details"
)
end
end
it
"should render title in milestones#index"
do
it
"should render title in milestones#index"
do
visit
namespace_project_milestones_path
(
project
.
namespace
,
project
)
visit
namespace_project_milestones_path
(
project
.
namespace
,
project
)
expect
(
page
).
to
have_link
(
"#
#{
issue
.
iid
}
"
)
expect
(
page
).
to
have_link
(
issue
.
to_reference
)
end
end
it
"should render title in milestones#show"
do
it
"should render title in milestones#show"
do
visit
namespace_project_milestone_path
(
project
.
namespace
,
project
,
@milestone
)
visit
namespace_project_milestone_path
(
project
.
namespace
,
project
,
@milestone
)
expect
(
page
).
to
have_link
(
"#
#{
issue
.
iid
}
"
)
expect
(
page
).
to
have_link
(
issue
.
to_reference
)
end
end
it
"should render description in milestones#show"
do
it
"should render description in milestones#show"
do
visit
namespace_project_milestone_path
(
project
.
namespace
,
project
,
@milestone
)
visit
namespace_project_milestone_path
(
project
.
namespace
,
project
,
@milestone
)
expect
(
page
).
to
have_link
(
"@
#{
fred
.
username
}
"
)
expect
(
page
).
to
have_link
(
fred
.
to_reference
)
end
end
end
end
end
end
spec/helpers/gitlab_markdown_helper_spec.rb
浏览文件 @
5a9c5520
...
@@ -26,7 +26,7 @@ describe GitlabMarkdownHelper do
...
@@ -26,7 +26,7 @@ describe GitlabMarkdownHelper do
end
end
describe
"referencing multiple objects"
do
describe
"referencing multiple objects"
do
let
(
:actual
)
{
"
!
#{
merge_request
.
iid
}
->
#{
commit
.
id
}
-> #
#{
issue
.
iid
}
"
}
let
(
:actual
)
{
"
#{
merge_request
.
to_reference
}
->
#{
commit
.
to_reference
}
->
#{
issue
.
to_reference
}
"
}
it
"should link to the merge request"
do
it
"should link to the merge request"
do
expected
=
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
expected
=
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
...
@@ -50,7 +50,7 @@ describe GitlabMarkdownHelper do
...
@@ -50,7 +50,7 @@ describe GitlabMarkdownHelper do
let
(
:issues
)
{
create_list
(
:issue
,
2
,
project:
project
)
}
let
(
:issues
)
{
create_list
(
:issue
,
2
,
project:
project
)
}
it
'should handle references nested in links with all the text'
do
it
'should handle references nested in links with all the text'
do
actual
=
link_to_gfm
(
"This should finally fix #
#{
issues
[
0
].
iid
}
and #
#{
issues
[
1
].
iid
}
for real"
,
commit_path
)
actual
=
link_to_gfm
(
"This should finally fix
#
{
issues
[
0
].
to_reference
}
and
#{
issues
[
1
].
to_reference
}
for real"
,
commit_path
)
doc
=
Nokogiri
::
HTML
.
parse
(
actual
)
doc
=
Nokogiri
::
HTML
.
parse
(
actual
)
# Make sure we didn't create invalid markup
# Make sure we didn't create invalid markup
...
@@ -63,7 +63,7 @@ describe GitlabMarkdownHelper do
...
@@ -63,7 +63,7 @@ describe GitlabMarkdownHelper do
# First issue link
# First issue link
expect
(
doc
.
css
(
'a'
)[
1
].
attr
(
'href'
)).
expect
(
doc
.
css
(
'a'
)[
1
].
attr
(
'href'
)).
to
eq
namespace_project_issue_path
(
project
.
namespace
,
project
,
issues
[
0
])
to
eq
namespace_project_issue_path
(
project
.
namespace
,
project
,
issues
[
0
])
expect
(
doc
.
css
(
'a'
)[
1
].
text
).
to
eq
"#
#{
issues
[
0
].
iid
}
"
expect
(
doc
.
css
(
'a'
)[
1
].
text
).
to
eq
issues
[
0
].
to_reference
# Internal commit link
# Internal commit link
expect
(
doc
.
css
(
'a'
)[
2
].
attr
(
'href'
)).
to
eq
commit_path
expect
(
doc
.
css
(
'a'
)[
2
].
attr
(
'href'
)).
to
eq
commit_path
...
@@ -72,7 +72,7 @@ describe GitlabMarkdownHelper do
...
@@ -72,7 +72,7 @@ describe GitlabMarkdownHelper do
# Second issue link
# Second issue link
expect
(
doc
.
css
(
'a'
)[
3
].
attr
(
'href'
)).
expect
(
doc
.
css
(
'a'
)[
3
].
attr
(
'href'
)).
to
eq
namespace_project_issue_path
(
project
.
namespace
,
project
,
issues
[
1
])
to
eq
namespace_project_issue_path
(
project
.
namespace
,
project
,
issues
[
1
])
expect
(
doc
.
css
(
'a'
)[
3
].
text
).
to
eq
"#
#{
issues
[
1
].
iid
}
"
expect
(
doc
.
css
(
'a'
)[
3
].
text
).
to
eq
issues
[
1
].
to_reference
# Trailing commit link
# Trailing commit link
expect
(
doc
.
css
(
'a'
)[
4
].
attr
(
'href'
)).
to
eq
commit_path
expect
(
doc
.
css
(
'a'
)[
4
].
attr
(
'href'
)).
to
eq
commit_path
...
@@ -90,7 +90,7 @@ describe GitlabMarkdownHelper do
...
@@ -90,7 +90,7 @@ describe GitlabMarkdownHelper do
end
end
it
"escapes HTML passed in as the body"
do
it
"escapes HTML passed in as the body"
do
actual
=
"This is a <h1>test</h1> - see #
#{
issues
[
0
].
iid
}
"
actual
=
"This is a <h1>test</h1> - see
#
{
issues
[
0
].
to_reference
}
"
expect
(
link_to_gfm
(
actual
,
commit_path
)).
expect
(
link_to_gfm
(
actual
,
commit_path
)).
to
match
(
'<h1>test</h1>'
)
to
match
(
'<h1>test</h1>'
)
end
end
...
...
spec/lib/gitlab/closing_issue_extractor_spec.rb
浏览文件 @
5a9c5520
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
ClosingIssueExtractor
do
describe
Gitlab
::
ClosingIssueExtractor
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:
iid1
)
{
issue
.
iid
}
let
(
:
reference
)
{
issue
.
to_reference
}
subject
{
described_class
.
new
(
project
,
project
.
creator
)
}
subject
{
described_class
.
new
(
project
,
project
.
creator
)
}
describe
"#closed_by_message"
do
describe
"#closed_by_message"
do
context
'with a single reference'
do
context
'with a single reference'
do
it
do
it
do
message
=
"Awesome commit (Closes #
#{
iid1
}
)"
message
=
"Awesome commit (Closes
#
{
reference
}
)"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Awesome commit (closes #
#{
iid1
}
)"
message
=
"Awesome commit (closes
#
{
reference
}
)"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Closed #
#{
iid1
}
"
message
=
"Closed
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"closed #
#{
iid1
}
"
message
=
"closed
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Closing #
#{
iid1
}
"
message
=
"Closing
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"closing #
#{
iid1
}
"
message
=
"closing
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Close #
#{
iid1
}
"
message
=
"Close
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"close #
#{
iid1
}
"
message
=
"close
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Awesome commit (Fixes #
#{
iid1
}
)"
message
=
"Awesome commit (Fixes
#
{
reference
}
)"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Awesome commit (fixes #
#{
iid1
}
)"
message
=
"Awesome commit (fixes
#
{
reference
}
)"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Fixed #
#{
iid1
}
"
message
=
"Fixed
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"fixed #
#{
iid1
}
"
message
=
"fixed
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Fixing #
#{
iid1
}
"
message
=
"Fixing
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"fixing #
#{
iid1
}
"
message
=
"fixing
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Fix #
#{
iid1
}
"
message
=
"Fix
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"fix #
#{
iid1
}
"
message
=
"fix
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Awesome commit (Resolves #
#{
iid1
}
)"
message
=
"Awesome commit (Resolves
#
{
reference
}
)"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Awesome commit (resolves #
#{
iid1
}
)"
message
=
"Awesome commit (resolves
#
{
reference
}
)"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Resolved #
#{
iid1
}
"
message
=
"Resolved
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"resolved #
#{
iid1
}
"
message
=
"resolved
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Resolving #
#{
iid1
}
"
message
=
"Resolving
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"resolving #
#{
iid1
}
"
message
=
"resolving
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"Resolve #
#{
iid1
}
"
message
=
"Resolve
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
it
do
it
do
message
=
"resolve #
#{
iid1
}
"
message
=
"resolve
#
{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
])
end
end
end
end
...
@@ -133,40 +133,40 @@ describe Gitlab::ClosingIssueExtractor do
...
@@ -133,40 +133,40 @@ describe Gitlab::ClosingIssueExtractor do
context
'with multiple references'
do
context
'with multiple references'
do
let
(
:other_issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:other_issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:third_issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:third_issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:
iid2
)
{
other_issue
.
iid
}
let
(
:
reference2
)
{
other_issue
.
to_reference
}
let
(
:
iid3
)
{
third_issue
.
iid
}
let
(
:
reference3
)
{
third_issue
.
to_reference
}
it
'fetches issues in single line message'
do
it
'fetches issues in single line message'
do
message
=
"Closes #
#{
iid1
}
and fix #
#{
iid
2
}
"
message
=
"Closes
#
{
reference
}
and fix #
#{
reference
2
}
"
expect
(
subject
.
closed_by_message
(
message
)).
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
,
other_issue
])
to
eq
([
issue
,
other_issue
])
end
end
it
'fetches comma-separated issues references in single line message'
do
it
'fetches comma-separated issues references in single line message'
do
message
=
"Closes #
#{
iid1
}
, closes #
#{
iid
2
}
"
message
=
"Closes
#
{
reference
}
, closes #
#{
reference
2
}
"
expect
(
subject
.
closed_by_message
(
message
)).
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
,
other_issue
])
to
eq
([
issue
,
other_issue
])
end
end
it
'fetches comma-separated issues numbers in single line message'
do
it
'fetches comma-separated issues numbers in single line message'
do
message
=
"Closes #
#{
iid1
}
, #
#{
iid2
}
and #
#{
iid
3
}
"
message
=
"Closes
#
{
reference
}
, #
#{
reference2
}
and #
#{
reference
3
}
"
expect
(
subject
.
closed_by_message
(
message
)).
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
,
other_issue
,
third_issue
])
to
eq
([
issue
,
other_issue
,
third_issue
])
end
end
it
'fetches issues in multi-line message'
do
it
'fetches issues in multi-line message'
do
message
=
"Awesome commit (closes #
#{
iid1
}
)
\n
Also fixes #
#{
iid
2
}
"
message
=
"Awesome commit (closes
#
{
reference
}
)
\n
Also fixes #
#{
reference
2
}
"
expect
(
subject
.
closed_by_message
(
message
)).
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
,
other_issue
])
to
eq
([
issue
,
other_issue
])
end
end
it
'fetches issues in hybrid message'
do
it
'fetches issues in hybrid message'
do
message
=
"Awesome commit (closes #
#{
iid1
}
)
\n
"
\
message
=
"Awesome commit (closes
#
{
reference
}
)
\n
"
\
"Also fixing issues #
#{
iid2
}
, #
#{
iid
3
}
and #4"
"Also fixing issues #
#{
reference2
}
, #
#{
reference
3
}
and #4"
expect
(
subject
.
closed_by_message
(
message
)).
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue
,
other_issue
,
third_issue
])
to
eq
([
issue
,
other_issue
,
third_issue
])
...
...
spec/lib/gitlab/reference_extractor_spec.rb
浏览文件 @
5a9c5520
...
@@ -20,7 +20,7 @@ describe Gitlab::ReferenceExtractor do
...
@@ -20,7 +20,7 @@ describe Gitlab::ReferenceExtractor do
@i0
=
create
(
:issue
,
project:
project
)
@i0
=
create
(
:issue
,
project:
project
)
@i1
=
create
(
:issue
,
project:
project
)
@i1
=
create
(
:issue
,
project:
project
)
subject
.
analyze
(
"#
#{
@i0
.
iid
}
, #
#{
@i1
.
iid
}
, and #
999."
)
subject
.
analyze
(
"
#
{
@i0
.
to_reference
}
,
#{
@i1
.
to_reference
}
, and
#{
Issue
.
reference_prefix
}
999."
)
expect
(
subject
.
issues
).
to
eq
([
@i0
,
@i1
])
expect
(
subject
.
issues
).
to
eq
([
@i0
,
@i1
])
end
end
...
@@ -82,7 +82,7 @@ describe Gitlab::ReferenceExtractor do
...
@@ -82,7 +82,7 @@ describe Gitlab::ReferenceExtractor do
end
end
it
'handles project issue references'
do
it
'handles project issue references'
do
subject
.
analyze
(
"this refers issue
#{
other_project
.
path_with_namespace
}
#
#{
issue
.
iid
}
"
)
subject
.
analyze
(
"this refers issue
#{
issue
.
to_reference
(
project
)
}
"
)
extracted
=
subject
.
issues
extracted
=
subject
.
issues
expect
(
extracted
.
size
).
to
eq
(
1
)
expect
(
extracted
.
size
).
to
eq
(
1
)
expect
(
extracted
).
to
eq
([
issue
])
expect
(
extracted
).
to
eq
([
issue
])
...
...
spec/models/merge_request_spec.rb
浏览文件 @
5a9c5520
...
@@ -129,7 +129,7 @@ describe MergeRequest do
...
@@ -129,7 +129,7 @@ describe MergeRequest do
it
'detects issues mentioned in the description'
do
it
'detects issues mentioned in the description'
do
issue2
=
create
(
:issue
,
project:
subject
.
project
)
issue2
=
create
(
:issue
,
project:
subject
.
project
)
subject
.
description
=
"Closes #
#{
issue2
.
iid
}
"
subject
.
description
=
"Closes
#
{
issue2
.
to_reference
}
"
subject
.
project
.
stub
(
default_branch:
subject
.
target_branch
)
subject
.
project
.
stub
(
default_branch:
subject
.
target_branch
)
expect
(
subject
.
closes_issues
).
to
include
(
issue2
)
expect
(
subject
.
closes_issues
).
to
include
(
issue2
)
...
...
spec/services/system_note_service_spec.rb
浏览文件 @
5a9c5520
...
@@ -238,13 +238,13 @@ describe SystemNoteService do
...
@@ -238,13 +238,13 @@ describe SystemNoteService do
let
(
:mentioner
)
{
project2
.
repository
.
commit
}
let
(
:mentioner
)
{
project2
.
repository
.
commit
}
it
'references the mentioning commit'
do
it
'references the mentioning commit'
do
expect
(
subject
.
note
).
to
eq
"mentioned in commit
#{
project2
.
path_with_namespace
}
@
#{
mentioner
.
id
}
"
expect
(
subject
.
note
).
to
eq
"mentioned in commit
#{
mentioner
.
to_reference
(
project
)
}
"
end
end
end
end
context
'from non-Commit'
do
context
'from non-Commit'
do
it
'references the mentioning object'
do
it
'references the mentioning object'
do
expect
(
subject
.
note
).
to
eq
"mentioned in issue
#{
project2
.
path_with_namespace
}
#
#{
mentioner
.
iid
}
"
expect
(
subject
.
note
).
to
eq
"mentioned in issue
#{
mentioner
.
to_reference
(
project
)
}
"
end
end
end
end
end
end
...
@@ -254,13 +254,13 @@ describe SystemNoteService do
...
@@ -254,13 +254,13 @@ describe SystemNoteService do
let
(
:mentioner
)
{
project
.
repository
.
commit
}
let
(
:mentioner
)
{
project
.
repository
.
commit
}
it
'references the mentioning commit'
do
it
'references the mentioning commit'
do
expect
(
subject
.
note
).
to
eq
"mentioned in commit
#{
mentioner
.
id
}
"
expect
(
subject
.
note
).
to
eq
"mentioned in commit
#{
mentioner
.
to_reference
}
"
end
end
end
end
context
'from non-Commit'
do
context
'from non-Commit'
do
it
'references the mentioning object'
do
it
'references the mentioning object'
do
expect
(
subject
.
note
).
to
eq
"mentioned in issue #
#{
mentioner
.
iid
}
"
expect
(
subject
.
note
).
to
eq
"mentioned in issue
#
{
mentioner
.
to_reference
}
"
end
end
end
end
end
end
...
@@ -270,7 +270,7 @@ describe SystemNoteService do
...
@@ -270,7 +270,7 @@ describe SystemNoteService do
describe
'.cross_reference?'
do
describe
'.cross_reference?'
do
it
'is truthy when text begins with expected text'
do
it
'is truthy when text begins with expected text'
do
expect
(
described_class
.
cross_reference?
(
'mentioned in
issue #1
'
)).
to
be_truthy
expect
(
described_class
.
cross_reference?
(
'mentioned in
something
'
)).
to
be_truthy
end
end
it
'is falsey when text does not begin with expected text'
do
it
'is falsey when text does not begin with expected text'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录