Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
2e0a8e919d6c
Commit
2e0a8e91
authored
Apr 30, 2015
by
Robert Speicher
Browse files
Add Project#get_issue
parent
6c2154061ab0
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/models/project.rb
View file @
2e0a8e91
...
...
@@ -329,5 +329,5 @@
self
.
id
end
def
issue
_exists?
(
issue_id
)
def
get_
issue
(
issue_id
)
if
default_issues_tracker?
...
...
@@ -333,3 +333,3 @@
if
default_issues_tracker?
self
.
issues
.
where
(
iid:
issue_id
)
.
first
.
present?
issues
.
find_by
(
iid:
issue_id
)
else
...
...
@@ -335,5 +335,5 @@
else
true
ExternalIssue
.
new
(
issue_id
,
self
)
end
end
...
...
@@ -337,6 +337,10 @@
end
end
def
issue_exists?
(
issue_id
)
get_issue
(
issue_id
).
present?
end
def
default_issue_tracker
gitlab_issue_tracker_service
||
create_gitlab_issue_tracker_service
end
...
...
@@ -350,11 +354,7 @@
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
View file @
2e0a8e91
...
...
@@ -44,6 +44,6 @@
# 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
)
...
...
@@ -48,6 +48,5 @@
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
)
...
...
@@ -53,3 +52,3 @@
url
=
url_for_issue
(
i
ssue
,
project
,
only_path:
context
[
:only_path
])
url
=
url_for_issue
(
i
d
,
project
,
only_path:
context
[
:only_path
])
...
...
@@ -55,6 +54,6 @@
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}"
...
...
@@ -57,8 +56,8 @@
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
View file @
2e0a8e91
...
...
@@ -27,7 +27,7 @@
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 @@
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 @@
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
...
...
Write
Preview
Supports
Markdown
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