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
Léo-Paul Géneau
gitlab-ce
Commits
467337fa
Commit
467337fa
authored
Dec 19, 2018
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add % prefix to milestone reference link text
Also update banzai tests to use reference_link_text
parent
62d250ff
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
16 deletions
+30
-16
app/models/milestone.rb
app/models/milestone.rb
+1
-1
changelogs/unreleased/53907-improve-milestone-links.yml
changelogs/unreleased/53907-improve-milestone-links.yml
+5
-0
spec/lib/banzai/filter/milestone_reference_filter_spec.rb
spec/lib/banzai/filter/milestone_reference_filter_spec.rb
+15
-15
spec/models/milestone_spec.rb
spec/models/milestone_spec.rb
+9
-0
No files found.
app/models/milestone.rb
View file @
467337fa
...
@@ -212,7 +212,7 @@ class Milestone < ActiveRecord::Base
...
@@ -212,7 +212,7 @@ class Milestone < ActiveRecord::Base
end
end
def
reference_link_text
(
from
=
nil
)
def
reference_link_text
(
from
=
nil
)
self
.
title
self
.
class
.
reference_prefix
+
self
.
title
end
end
def
milestoneish_ids
def
milestoneish_ids
...
...
changelogs/unreleased/53907-improve-milestone-links.yml
0 → 100644
View file @
467337fa
---
title
:
Add % prefix to milestone reference links
merge_request
:
23928
author
:
type
:
changed
spec/lib/banzai/filter/milestone_reference_filter_spec.rb
View file @
467337fa
...
@@ -59,7 +59,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
...
@@ -59,7 +59,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
it
'links with adjacent text'
do
it
'links with adjacent text'
do
doc
=
reference_filter
(
"Milestone (
#{
reference
}
.)"
)
doc
=
reference_filter
(
"Milestone (
#{
reference
}
.)"
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+>
#{
milestone
.
name
}
</a>
\.\)
)
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+>
#{
milestone
.
reference_link_text
}
</a>
\.\)
)
)
end
end
it
'ignores invalid milestone IIDs'
do
it
'ignores invalid milestone IIDs'
do
...
@@ -80,12 +80,12 @@ describe Banzai::Filter::MilestoneReferenceFilter do
...
@@ -80,12 +80,12 @@ describe Banzai::Filter::MilestoneReferenceFilter do
doc
=
reference_filter
(
"See
#{
reference
}
"
)
doc
=
reference_filter
(
"See
#{
reference
}
"
)
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
urls
.
milestone_url
(
milestone
)
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
urls
.
milestone_url
(
milestone
)
expect
(
doc
.
text
).
to
eq
'See gfm'
expect
(
doc
.
text
).
to
eq
"See
#{
milestone
.
reference_link_text
}
"
end
end
it
'links with adjacent text'
do
it
'links with adjacent text'
do
doc
=
reference_filter
(
"Milestone (
#{
reference
}
.)"
)
doc
=
reference_filter
(
"Milestone (
#{
reference
}
.)"
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+>
#{
milestone
.
name
}
</a>
\.\)
)
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+>
#{
milestone
.
reference_link_text
}
</a>
\.\)
)
)
end
end
it
'ignores invalid milestone names'
do
it
'ignores invalid milestone names'
do
...
@@ -106,12 +106,12 @@ describe Banzai::Filter::MilestoneReferenceFilter do
...
@@ -106,12 +106,12 @@ describe Banzai::Filter::MilestoneReferenceFilter do
doc
=
reference_filter
(
"See
#{
reference
}
"
)
doc
=
reference_filter
(
"See
#{
reference
}
"
)
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
urls
.
milestone_url
(
milestone
)
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
urls
.
milestone_url
(
milestone
)
expect
(
doc
.
text
).
to
eq
'See gfm references'
expect
(
doc
.
text
).
to
eq
"See
#{
milestone
.
reference_link_text
}
"
end
end
it
'links with adjacent text'
do
it
'links with adjacent text'
do
doc
=
reference_filter
(
"Milestone (
#{
reference
}
.)"
)
doc
=
reference_filter
(
"Milestone (
#{
reference
}
.)"
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+>
#{
milestone
.
name
}
</a>
\.\)
)
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+>
#{
milestone
.
reference_link_text
}
</a>
\.\)
)
)
end
end
it
'ignores invalid milestone names'
do
it
'ignores invalid milestone names'
do
...
@@ -201,14 +201,14 @@ describe Banzai::Filter::MilestoneReferenceFilter do
...
@@ -201,14 +201,14 @@ describe Banzai::Filter::MilestoneReferenceFilter do
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
.
to
eq
(
"
#{
milestone
.
name
}
in
#{
another_project
.
full_path
}
"
)
.
to
eq
(
"
#{
milestone
.
reference_link_text
}
in
#{
another_project
.
full_path
}
"
)
end
end
it
'has valid text'
do
it
'has valid text'
do
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
expect
(
doc
.
text
)
expect
(
doc
.
text
)
.
to
eq
(
"See (
#{
milestone
.
name
}
in
#{
another_project
.
full_path
}
.)"
)
.
to
eq
(
"See (
#{
milestone
.
reference_link_text
}
in
#{
another_project
.
full_path
}
.)"
)
end
end
it
'escapes the name attribute'
do
it
'escapes the name attribute'
do
...
@@ -217,7 +217,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
...
@@ -217,7 +217,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
doc
=
reference_filter
(
"See
#{
reference
}
"
)
doc
=
reference_filter
(
"See
#{
reference
}
"
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
.
to
eq
"
#{
milestone
.
name
}
in
#{
another_project
.
full_path
}
"
.
to
eq
"
#{
milestone
.
reference_link_text
}
in
#{
another_project
.
full_path
}
"
end
end
end
end
...
@@ -238,14 +238,14 @@ describe Banzai::Filter::MilestoneReferenceFilter do
...
@@ -238,14 +238,14 @@ describe Banzai::Filter::MilestoneReferenceFilter do
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
.
to
eq
(
"
#{
milestone
.
name
}
in
#{
another_project
.
path
}
"
)
.
to
eq
(
"
#{
milestone
.
reference_link_text
}
in
#{
another_project
.
path
}
"
)
end
end
it
'has valid text'
do
it
'has valid text'
do
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
expect
(
doc
.
text
)
expect
(
doc
.
text
)
.
to
eq
(
"See (
#{
milestone
.
name
}
in
#{
another_project
.
path
}
.)"
)
.
to
eq
(
"See (
#{
milestone
.
reference_link_text
}
in
#{
another_project
.
path
}
.)"
)
end
end
it
'escapes the name attribute'
do
it
'escapes the name attribute'
do
...
@@ -254,7 +254,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
...
@@ -254,7 +254,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
doc
=
reference_filter
(
"See
#{
reference
}
"
)
doc
=
reference_filter
(
"See
#{
reference
}
"
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
.
to
eq
"
#{
milestone
.
name
}
in
#{
another_project
.
path
}
"
.
to
eq
"
#{
milestone
.
reference_link_text
}
in
#{
another_project
.
path
}
"
end
end
end
end
...
@@ -275,14 +275,14 @@ describe Banzai::Filter::MilestoneReferenceFilter do
...
@@ -275,14 +275,14 @@ describe Banzai::Filter::MilestoneReferenceFilter do
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
.
to
eq
(
"
#{
milestone
.
name
}
in
#{
another_project
.
path
}
"
)
.
to
eq
(
"
#{
milestone
.
reference_link_text
}
in
#{
another_project
.
path
}
"
)
end
end
it
'has valid text'
do
it
'has valid text'
do
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
doc
=
reference_filter
(
"See (
#{
reference
}
.)"
)
expect
(
doc
.
text
)
expect
(
doc
.
text
)
.
to
eq
(
"See (
#{
milestone
.
name
}
in
#{
another_project
.
path
}
.)"
)
.
to
eq
(
"See (
#{
milestone
.
reference_link_text
}
in
#{
another_project
.
path
}
.)"
)
end
end
it
'escapes the name attribute'
do
it
'escapes the name attribute'
do
...
@@ -291,7 +291,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
...
@@ -291,7 +291,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
doc
=
reference_filter
(
"See
#{
reference
}
"
)
doc
=
reference_filter
(
"See
#{
reference
}
"
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
expect
(
doc
.
css
(
'a'
).
first
.
text
)
.
to
eq
"
#{
milestone
.
name
}
in
#{
another_project
.
path
}
"
.
to
eq
"
#{
milestone
.
reference_link_text
}
in
#{
another_project
.
path
}
"
end
end
end
end
...
@@ -346,7 +346,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
...
@@ -346,7 +346,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
milestone
.
update!
(
group:
parent_group
)
milestone
.
update!
(
group:
parent_group
)
doc
=
reference_filter
(
"See
#{
reference
}
"
)
doc
=
reference_filter
(
"See
#{
reference
}
"
)
expect
(
doc
.
css
(
'a'
).
first
.
text
).
to
eq
(
milestone
.
name
)
expect
(
doc
.
css
(
'a'
).
first
.
text
).
to
eq
(
milestone
.
reference_link_text
)
end
end
end
end
...
...
spec/models/milestone_spec.rb
View file @
467337fa
...
@@ -316,6 +316,15 @@ describe Milestone do
...
@@ -316,6 +316,15 @@ describe Milestone do
end
end
end
end
describe
'#reference_link_text'
do
let
(
:project
)
{
build_stubbed
(
:project
,
name:
'sample-project'
)
}
let
(
:milestone
)
{
build_stubbed
(
:milestone
,
iid:
1
,
project:
project
,
name:
'milestone'
)
}
it
'returns the title with the reference prefix'
do
expect
(
milestone
.
reference_link_text
).
to
eq
'%milestone'
end
end
describe
'#participants'
do
describe
'#participants'
do
let
(
:project
)
{
build
(
:project
,
name:
'sample-project'
)
}
let
(
:project
)
{
build
(
:project
,
name:
'sample-project'
)
}
let
(
:milestone
)
{
build
(
:milestone
,
iid:
1
,
project:
project
)
}
let
(
:milestone
)
{
build
(
:milestone
,
iid:
1
,
project:
project
)
}
...
...
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