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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
de71a465
Commit
de71a465
authored
Apr 19, 2017
by
Adam Niedzielski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display issuable state only in notes and issuable description
Closes #30964
parent
bbd83376
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
13 deletions
+25
-13
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+1
-1
app/models/note.rb
app/models/note.rb
+1
-1
lib/banzai/filter/issuable_state_filter.rb
lib/banzai/filter/issuable_state_filter.rb
+2
-0
spec/lib/banzai/filter/issuable_state_filter_spec.rb
spec/lib/banzai/filter/issuable_state_filter_spec.rb
+21
-11
No files found.
app/models/concerns/issuable.rb
View file @
de71a465
...
@@ -23,7 +23,7 @@ module Issuable
...
@@ -23,7 +23,7 @@ module Issuable
included
do
included
do
cache_markdown_field
:title
,
pipeline: :single_line
cache_markdown_field
:title
,
pipeline: :single_line
cache_markdown_field
:description
cache_markdown_field
:description
,
issuable_state_filter_enabled:
true
belongs_to
:author
,
class_name:
"User"
belongs_to
:author
,
class_name:
"User"
belongs_to
:assignee
,
class_name:
"User"
belongs_to
:assignee
,
class_name:
"User"
...
...
app/models/note.rb
View file @
de71a465
...
@@ -16,7 +16,7 @@ class Note < ActiveRecord::Base
...
@@ -16,7 +16,7 @@ class Note < ActiveRecord::Base
ignore_column
:original_discussion_id
ignore_column
:original_discussion_id
cache_markdown_field
:note
,
pipeline: :note
cache_markdown_field
:note
,
pipeline: :note
,
issuable_state_filter_enabled:
true
# Attribute containing rendered and redacted Markdown as generated by
# Attribute containing rendered and redacted Markdown as generated by
# Banzai::ObjectRenderer.
# Banzai::ObjectRenderer.
...
...
lib/banzai/filter/issuable_state_filter.rb
View file @
de71a465
...
@@ -9,6 +9,8 @@ module Banzai
...
@@ -9,6 +9,8 @@ module Banzai
VISIBLE_STATES
=
%w(closed merged)
.
freeze
VISIBLE_STATES
=
%w(closed merged)
.
freeze
def
call
def
call
return
doc
unless
context
[
:issuable_state_filter_enabled
]
extractor
=
Banzai
::
IssuableExtractor
.
new
(
project
,
current_user
)
extractor
=
Banzai
::
IssuableExtractor
.
new
(
project
,
current_user
)
issuables
=
extractor
.
extract
([
doc
])
issuables
=
extractor
.
extract
([
doc
])
...
...
spec/lib/banzai/filter/issuable_state_filter_spec.rb
View file @
de71a465
...
@@ -5,6 +5,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -5,6 +5,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
include
FilterSpecHelper
include
FilterSpecHelper
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:context
)
{
{
current_user:
user
,
issuable_state_filter_enabled:
true
}
}
def
create_link
(
text
,
data
)
def
create_link
(
text
,
data
)
link_to
(
text
,
''
,
class:
'gfm has-tooltip'
,
data:
data
)
link_to
(
text
,
''
,
class:
'gfm has-tooltip'
,
data:
data
)
...
@@ -20,7 +21,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -20,7 +21,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
it
'ignores non-issuable links'
do
it
'ignores non-issuable links'
do
project
=
create
(
:empty_project
,
:public
)
project
=
create
(
:empty_project
,
:public
)
link
=
create_link
(
'text'
,
project:
project
,
reference_type:
'issue'
)
link
=
create_link
(
'text'
,
project:
project
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
c
urrent_user:
user
)
doc
=
filter
(
link
,
c
ontext
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
end
end
...
@@ -28,7 +29,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -28,7 +29,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
it
'ignores issuable links with empty content'
do
it
'ignores issuable links with empty content'
do
issue
=
create
(
:issue
,
:closed
)
issue
=
create
(
:issue
,
:closed
)
link
=
create_link
(
''
,
issue:
issue
.
id
,
reference_type:
'issue'
)
link
=
create_link
(
''
,
issue:
issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
c
urrent_user:
user
)
doc
=
filter
(
link
,
c
ontext
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
''
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
''
)
end
end
...
@@ -40,17 +41,26 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -40,17 +41,26 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
issue:
issue
.
id
,
issue:
issue
.
id
,
reference_type:
'issue'
reference_type:
'issue'
)
)
doc
=
filter
(
link
,
c
urrent_user:
user
)
doc
=
filter
(
link
,
c
ontext
)
expect
(
doc
.
css
(
'a'
).
last
.
inner_html
).
expect
(
doc
.
css
(
'a'
).
last
.
inner_html
).
to
eq
(
'something <strong>else</strong> [closed]'
)
to
eq
(
'something <strong>else</strong> [closed]'
)
end
end
it
'does not append state when filter is not enabled'
do
issue
=
create
(
:issue
,
:closed
)
link
=
create_link
(
'text'
,
issue:
issue
.
id
,
reference_type:
'issue'
)
context
=
{
current_user:
user
}
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
end
context
'for issue references'
do
context
'for issue references'
do
it
'ignores open issue references'
do
it
'ignores open issue references'
do
issue
=
create
(
:issue
)
issue
=
create
(
:issue
)
link
=
create_link
(
'text'
,
issue:
issue
.
id
,
reference_type:
'issue'
)
link
=
create_link
(
'text'
,
issue:
issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
c
urrent_user:
user
)
doc
=
filter
(
link
,
c
ontext
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
end
end
...
@@ -58,7 +68,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -58,7 +68,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
it
'ignores reopened issue references'
do
it
'ignores reopened issue references'
do
reopened_issue
=
create
(
:issue
,
:reopened
)
reopened_issue
=
create
(
:issue
,
:reopened
)
link
=
create_link
(
'text'
,
issue:
reopened_issue
.
id
,
reference_type:
'issue'
)
link
=
create_link
(
'text'
,
issue:
reopened_issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
c
urrent_user:
user
)
doc
=
filter
(
link
,
c
ontext
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
end
end
...
@@ -66,7 +76,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -66,7 +76,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
it
'appends [closed] to closed issue references'
do
it
'appends [closed] to closed issue references'
do
closed_issue
=
create
(
:issue
,
:closed
)
closed_issue
=
create
(
:issue
,
:closed
)
link
=
create_link
(
'text'
,
issue:
closed_issue
.
id
,
reference_type:
'issue'
)
link
=
create_link
(
'text'
,
issue:
closed_issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
c
urrent_user:
user
)
doc
=
filter
(
link
,
c
ontext
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text [closed]'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text [closed]'
)
end
end
...
@@ -76,7 +86,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -76,7 +86,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
it
'ignores open merge request references'
do
it
'ignores open merge request references'
do
mr
=
create
(
:merge_request
)
mr
=
create
(
:merge_request
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
c
urrent_user:
user
)
doc
=
filter
(
link
,
c
ontext
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
end
end
...
@@ -84,7 +94,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -84,7 +94,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
it
'ignores reopened merge request references'
do
it
'ignores reopened merge request references'
do
mr
=
create
(
:merge_request
,
:reopened
)
mr
=
create
(
:merge_request
,
:reopened
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
c
urrent_user:
user
)
doc
=
filter
(
link
,
c
ontext
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
end
end
...
@@ -92,7 +102,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -92,7 +102,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
it
'ignores locked merge request references'
do
it
'ignores locked merge request references'
do
mr
=
create
(
:merge_request
,
:locked
)
mr
=
create
(
:merge_request
,
:locked
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
c
urrent_user:
user
)
doc
=
filter
(
link
,
c
ontext
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text'
)
end
end
...
@@ -100,7 +110,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -100,7 +110,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
it
'appends [closed] to closed merge request references'
do
it
'appends [closed] to closed merge request references'
do
mr
=
create
(
:merge_request
,
:closed
)
mr
=
create
(
:merge_request
,
:closed
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
c
urrent_user:
user
)
doc
=
filter
(
link
,
c
ontext
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text [closed]'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text [closed]'
)
end
end
...
@@ -108,7 +118,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -108,7 +118,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
it
'appends [merged] to merged merge request references'
do
it
'appends [merged] to merged merge request references'
do
mr
=
create
(
:merge_request
,
:merged
)
mr
=
create
(
:merge_request
,
:merged
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
link
=
create_link
(
'text'
,
merge_request:
mr
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
c
urrent_user:
user
)
doc
=
filter
(
link
,
c
ontext
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text [merged]'
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
'text [merged]'
)
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