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
1269ee4c
Commit
1269ee4c
authored
Apr 19, 2017
by
Adam Niedzielski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not append issuable state to links with custom anchor
Closes #30916 Change the presentation from [closed] to (closed)
parent
29ddc15f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
34 deletions
+78
-34
issuable_state_filter.rb
lib/banzai/filter/issuable_state_filter.rb
+2
-2
issuable_state_filter_spec.rb
spec/lib/banzai/filter/issuable_state_filter_spec.rb
+76
-32
No files found.
lib/banzai/filter/issuable_state_filter.rb
View file @
1269ee4c
...
...
@@ -15,8 +15,8 @@ module Banzai
issuables
=
extractor
.
extract
([
doc
])
issuables
.
each
do
|
node
,
issuable
|
if
VISIBLE_STATES
.
include?
(
issuable
.
state
)
&&
node
.
children
.
present?
node
.
add_child
(
Nokogiri
::
XML
::
Text
.
new
(
" [
#{
issuable
.
state
}
]"
,
doc
))
if
VISIBLE_STATES
.
include?
(
issuable
.
state
)
&&
node
.
inner_html
==
issuable
.
reference_link_text
(
project
)
node
.
content
+=
" (
#{
issuable
.
state
}
)"
end
end
...
...
spec/lib/banzai/filter/issuable_state_filter_spec.rb
View file @
1269ee4c
...
...
@@ -34,17 +34,41 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
''
)
end
it
'
adds text with standard formatting
'
do
it
'
ignores issuable links with custom anchor
'
do
issue
=
create
(
:issue
,
:closed
)
link
=
create_link
(
'something'
,
issue:
issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'something'
)
end
it
'ignores issuable links to specific comments'
do
issue
=
create
(
:issue
,
:closed
)
link
=
create_link
(
"
#{
issue
.
to_reference
}
(comment 1)"
,
issue:
issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
"
#{
issue
.
to_reference
}
(comment 1)"
)
end
it
'ignores merge request links to diffs tab'
do
merge_request
=
create
(
:merge_request
,
:closed
)
link
=
create_link
(
'something <strong>else</strong>'
.
html_safe
,
issue:
issue
.
id
,
reference_type:
'
issue
'
"
#{
merge_request
.
to_reference
}
(diffs)"
,
merge_request:
merge_request
.
id
,
reference_type:
'
merge_request
'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
inner_html
).
to
eq
(
'something <strong>else</strong> [closed]'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
"
#{
merge_request
.
to_reference
}
(diffs)"
)
end
it
'handles cross project references'
do
issue
=
create
(
:issue
,
:closed
)
project
=
create
(
:empty_project
)
link
=
create_link
(
issue
.
to_reference
(
project
),
issue:
issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
context
.
merge
(
project:
project
))
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
"
#{
issue
.
to_reference
(
project
)
}
(closed)"
)
end
it
'does not append state when filter is not enabled'
do
...
...
@@ -59,68 +83,88 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
context
'for issue references'
do
it
'ignores open issue references'
do
issue
=
create
(
:issue
)
link
=
create_link
(
'text'
,
issue:
issue
.
id
,
reference_type:
'issue'
)
link
=
create_link
(
issue
.
to_reference
,
issue:
issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
issue
.
to_reference
)
end
it
'ignores reopened issue references'
do
reopened_
issue
=
create
(
:issue
,
:reopened
)
link
=
create_link
(
'text'
,
issue:
reopened_
issue
.
id
,
reference_type:
'issue'
)
issue
=
create
(
:issue
,
:reopened
)
link
=
create_link
(
issue
.
to_reference
,
issue:
issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
issue
.
to_reference
)
end
it
'appends
[closed]
to closed issue references'
do
closed_
issue
=
create
(
:issue
,
:closed
)
link
=
create_link
(
'text'
,
issue:
closed_
issue
.
id
,
reference_type:
'issue'
)
it
'appends
state
to closed issue references'
do
issue
=
create
(
:issue
,
:closed
)
link
=
create_link
(
issue
.
to_reference
,
issue:
issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text [closed]'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
"
#{
issue
.
to_reference
}
(closed)"
)
end
end
context
'for merge request references'
do
it
'ignores open merge request references'
do
mr
=
create
(
:merge_request
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
merge_request
=
create
(
:merge_request
)
link
=
create_link
(
merge_request
.
to_reference
,
merge_request:
merge_request
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
merge_request
.
to_reference
)
end
it
'ignores reopened merge request references'
do
mr
=
create
(
:merge_request
,
:reopened
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
merge_request
=
create
(
:merge_request
,
:reopened
)
link
=
create_link
(
merge_request
.
to_reference
,
merge_request:
merge_request
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
merge_request
.
to_reference
)
end
it
'ignores locked merge request references'
do
mr
=
create
(
:merge_request
,
:locked
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
merge_request
=
create
(
:merge_request
,
:locked
)
link
=
create_link
(
merge_request
.
to_reference
,
merge_request:
merge_request
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
merge_request
.
to_reference
)
end
it
'appends [closed] to closed merge request references'
do
mr
=
create
(
:merge_request
,
:closed
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
it
'appends state to closed merge request references'
do
merge_request
=
create
(
:merge_request
,
:closed
)
link
=
create_link
(
merge_request
.
to_reference
,
merge_request:
merge_request
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text [closed]'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
"
#{
merge_request
.
to_reference
}
(closed)"
)
end
it
'appends [merged] to merged merge request references'
do
mr
=
create
(
:merge_request
,
:merged
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
it
'appends state to merged merge request references'
do
merge_request
=
create
(
:merge_request
,
:merged
)
link
=
create_link
(
merge_request
.
to_reference
,
merge_request:
merge_request
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text [merged]'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
"
#{
merge_request
.
to_reference
}
(merged)"
)
end
end
end
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