Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
0027c2dd
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,发现更多精彩内容 >>
提交
0027c2dd
编写于
4月 30, 2015
作者:
R
Robert Speicher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Project#get_issue
上级
466bec7c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
18 addition
and
19 deletion
+18
-19
app/models/project.rb
app/models/project.rb
+8
-8
lib/gitlab/markdown/issue_reference_filter.rb
lib/gitlab/markdown/issue_reference_filter.rb
+6
-7
spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
+4
-4
未找到文件。
app/models/project.rb
浏览文件 @
0027c2dd
...
...
@@ -329,12 +329,16 @@ class Project < ActiveRecord::Base
self
.
id
end
def
issue_exists?
(
issue_id
)
def
get_issue
(
issue_id
)
if
default_issues_tracker?
self
.
issues
.
where
(
iid:
issue_id
).
first
.
present?
issues
.
find_by
(
iid:
issue_id
)
else
true
ExternalIssue
.
new
(
issue_id
,
self
)
end
end
def
issue_exists?
(
issue_id
)
get_issue
(
issue_id
).
present?
end
def
default_issue_tracker
...
...
@@ -350,11 +354,7 @@ class Project < ActiveRecord::Base
end
def
default_issues_tracker?
if
external_issue_tracker
false
else
true
end
external_issue_tracker
.
blank?
end
def
external_issues_trackers
...
...
lib/gitlab/markdown/issue_reference_filter.rb
浏览文件 @
0027c2dd
...
...
@@ -44,21 +44,20 @@ module Gitlab
# Returns a String with `#123` references replaced with links. All links
# have `gfm` and `gfm-issue` class names attached for styling.
def
issue_link_filter
(
text
)
self
.
class
.
references_in
(
text
)
do
|
match
,
i
ssue
,
project_ref
|
self
.
class
.
references_in
(
text
)
do
|
match
,
i
d
,
project_ref
|
project
=
self
.
project_from_ref
(
project_ref
)
if
project
&&
project
.
issue_exists?
(
issue
)
# FIXME (rspeicher): Law of Demeter
push_result
(
:issue
,
project
.
issues
.
where
(
iid:
issue
).
first
)
if
project
&&
issue
=
project
.
get_issue
(
id
)
push_result
(
:issue
,
issue
)
url
=
url_for_issue
(
i
ssue
,
project
,
only_path:
context
[
:only_path
])
url
=
url_for_issue
(
i
d
,
project
,
only_path:
context
[
:only_path
])
title
=
escape_once
(
"Issue:
#{
title_for_issue
(
i
ssue
,
project
)
}
"
)
title
=
escape_once
(
"Issue:
#{
title_for_issue
(
i
d
,
project
)
}
"
)
klass
=
reference_class
(
:issue
)
%(<a href="#{url}"
title="#{title}"
class="#{klass}">#{project_ref}##{i
ssue
}</a>)
class="#{klass}">#{project_ref}##{i
d
}</a>)
else
match
end
...
...
spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
浏览文件 @
0027c2dd
...
...
@@ -27,7 +27,7 @@ module Gitlab::Markdown
let
(
:reference
)
{
"#
#{
issue
.
iid
}
"
}
it
'ignores valid references when using non-default tracker'
do
expect
(
project
).
to
receive
(
:
issue_exists?
).
with
(
issue
.
iid
).
and_return
(
false
)
expect
(
project
).
to
receive
(
:
get_issue
).
with
(
issue
.
iid
).
and_return
(
nil
)
exp
=
act
=
"Issue #
#{
issue
.
iid
}
"
expect
(
filter
(
act
).
to_html
).
to
eq
exp
...
...
@@ -48,7 +48,7 @@ module Gitlab::Markdown
it
'ignores invalid issue IDs'
do
exp
=
act
=
"Fixed #
#{
issue
.
iid
+
1
}
"
expect
(
project
).
to
receive
(
:
issue_exists?
).
with
(
issue
.
iid
+
1
)
expect
(
project
).
to
receive
(
:
get_issue
).
with
(
issue
.
iid
+
1
).
and_return
(
nil
)
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
...
...
@@ -98,8 +98,8 @@ module Gitlab::Markdown
before
{
allow_cross_reference!
}
it
'ignores valid references when cross-reference project uses external tracker'
do
expect_any_instance_of
(
Project
).
to
receive
(
:
issue_exists?
).
with
(
issue
.
iid
).
and_return
(
false
)
expect_any_instance_of
(
Project
).
to
receive
(
:
get_issue
).
with
(
issue
.
iid
).
and_return
(
nil
)
exp
=
act
=
"Issue #
#{
issue
.
iid
}
"
expect
(
filter
(
act
).
to_html
).
to
eq
exp
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录