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
611912fe
Commit
611912fe
authored
Dec 07, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store the demodulized reference filter name in data attribute
parent
d611a387
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
18 deletions
+18
-18
reference_gatherer_filter.rb
lib/gitlab/markdown/filter/reference_gatherer_filter.rb
+1
-1
reference_filter.rb
lib/gitlab/markdown/reference_filter.rb
+3
-3
redactor_filter_spec.rb
spec/lib/gitlab/markdown/filter/redactor_filter_spec.rb
+7
-7
reference_gatherer_filter_spec.rb
.../gitlab/markdown/filter/reference_gatherer_filter_spec.rb
+7
-7
No files found.
lib/gitlab/markdown/filter/reference_gatherer_filter.rb
View file @
611912fe
...
...
@@ -31,7 +31,7 @@ module Gitlab
return
unless
node
.
has_attribute?
(
'data-reference-filter'
)
reference_type
=
node
.
attr
(
'data-reference-filter'
)
reference_filter
=
reference_type
.
constantize
reference_filter
=
Gitlab
::
Markdown
.
const_get
(
reference_type
)
return
if
context
[
:reference_filter
]
&&
reference_filter
!=
context
[
:reference_filter
]
...
...
lib/gitlab/markdown/reference_filter.rb
View file @
611912fe
...
...
@@ -57,14 +57,14 @@ module Gitlab
# Examples:
#
# data_attribute(project: 1, issue: 2)
# # => "data-reference-filter=\"
Gitlab::Markdown::
SomeReferenceFilter\" data-project=\"1\" data-issue=\"2\""
# # => "data-reference-filter=\"SomeReferenceFilter\" data-project=\"1\" data-issue=\"2\""
#
# data_attribute(project: 3, merge_request: 4)
# # => "data-reference-filter=\"
Gitlab::Markdown::
SomeReferenceFilter\" data-project=\"3\" data-merge-request=\"4\""
# # => "data-reference-filter=\"SomeReferenceFilter\" data-project=\"3\" data-merge-request=\"4\""
#
# Returns a String
def
data_attribute
(
attributes
=
{})
attributes
[
:reference_filter
]
=
self
.
class
.
name
attributes
[
:reference_filter
]
=
self
.
class
.
name
.
demodulize
attributes
.
map
{
|
key
,
value
|
%Q(data-
#{
key
.
to_s
.
dasherize
}
="
#{
value
}
")
}.
join
(
" "
)
end
...
...
spec/lib/gitlab/markdown/filter/redactor_filter_spec.rb
View file @
611912fe
...
...
@@ -20,7 +20,7 @@ describe Gitlab::Markdown::RedactorFilter do
user
=
create
(
:user
)
project
=
create
(
:empty_project
)
link
=
reference_link
(
project:
project
.
id
,
reference_filter:
Gitlab
::
Markdown
::
ReferenceFilter
.
name
)
link
=
reference_link
(
project:
project
.
id
,
reference_filter:
'ReferenceFilter'
)
doc
=
filter
(
link
,
current_user:
user
)
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
0
...
...
@@ -31,14 +31,14 @@ describe Gitlab::Markdown::RedactorFilter do
project
=
create
(
:empty_project
)
project
.
team
<<
[
user
,
:master
]
link
=
reference_link
(
project:
project
.
id
,
reference_filter:
Gitlab
::
Markdown
::
ReferenceFilter
.
name
)
link
=
reference_link
(
project:
project
.
id
,
reference_filter:
'ReferenceFilter'
)
doc
=
filter
(
link
,
current_user:
user
)
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
1
end
it
'handles invalid Project references'
do
link
=
reference_link
(
project:
12345
,
reference_filter:
Gitlab
::
Markdown
::
ReferenceFilter
.
name
)
link
=
reference_link
(
project:
12345
,
reference_filter:
'ReferenceFilter'
)
expect
{
filter
(
link
)
}.
not_to
raise_error
end
...
...
@@ -51,7 +51,7 @@ describe Gitlab::Markdown::RedactorFilter do
user
=
create
(
:user
)
group
=
create
(
:group
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
Gitlab
::
Markdown
::
UserReferenceFilter
.
name
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
'UserReferenceFilter'
)
doc
=
filter
(
link
,
current_user:
user
)
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
0
...
...
@@ -62,14 +62,14 @@ describe Gitlab::Markdown::RedactorFilter do
group
=
create
(
:group
)
group
.
add_developer
(
user
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
Gitlab
::
Markdown
::
UserReferenceFilter
.
name
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
'UserReferenceFilter'
)
doc
=
filter
(
link
,
current_user:
user
)
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
1
end
it
'handles invalid Group references'
do
link
=
reference_link
(
group:
12345
,
reference_filter:
Gitlab
::
Markdown
::
UserReferenceFilter
.
name
)
link
=
reference_link
(
group:
12345
,
reference_filter:
'UserReferenceFilter'
)
expect
{
filter
(
link
)
}.
not_to
raise_error
end
...
...
@@ -79,7 +79,7 @@ describe Gitlab::Markdown::RedactorFilter do
it
'allows any User reference'
do
user
=
create
(
:user
)
link
=
reference_link
(
user:
user
.
id
,
reference_filter:
Gitlab
::
Markdown
::
UserReferenceFilter
.
name
)
link
=
reference_link
(
user:
user
.
id
,
reference_filter:
'UserReferenceFilter'
)
doc
=
filter
(
link
)
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
1
...
...
spec/lib/gitlab/markdown/filter/reference_gatherer_filter_spec.rb
View file @
611912fe
...
...
@@ -16,7 +16,7 @@ describe Gitlab::Markdown::ReferenceGathererFilter do
project
=
create
(
:empty_project
)
issue
=
create
(
:issue
,
project:
project
)
link
=
reference_link
(
project:
project
.
id
,
issue:
issue
.
id
,
reference_filter:
Gitlab
::
Markdown
::
IssueReferenceFilter
.
name
)
link
=
reference_link
(
project:
project
.
id
,
issue:
issue
.
id
,
reference_filter:
'IssueReferenceFilter'
)
result
=
pipeline_result
(
link
,
current_user:
user
)
expect
(
result
[
:references
][
:issue
]).
to
be_empty
...
...
@@ -28,14 +28,14 @@ describe Gitlab::Markdown::ReferenceGathererFilter do
issue
=
create
(
:issue
,
project:
project
)
project
.
team
<<
[
user
,
:master
]
link
=
reference_link
(
project:
project
.
id
,
issue:
issue
.
id
,
reference_filter:
Gitlab
::
Markdown
::
IssueReferenceFilter
.
name
)
link
=
reference_link
(
project:
project
.
id
,
issue:
issue
.
id
,
reference_filter:
'IssueReferenceFilter'
)
result
=
pipeline_result
(
link
,
current_user:
user
)
expect
(
result
[
:references
][
:issue
]).
to
eq
([
issue
])
end
it
'handles invalid Project references'
do
link
=
reference_link
(
project:
12345
,
issue:
12345
,
reference_filter:
Gitlab
::
Markdown
::
IssueReferenceFilter
.
name
)
link
=
reference_link
(
project:
12345
,
issue:
12345
,
reference_filter:
'IssueReferenceFilter'
)
expect
{
pipeline_result
(
link
)
}.
not_to
raise_error
end
...
...
@@ -49,7 +49,7 @@ describe Gitlab::Markdown::ReferenceGathererFilter do
user
=
create
(
:user
)
group
=
create
(
:group
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
Gitlab
::
Markdown
::
UserReferenceFilter
.
name
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
'UserReferenceFilter'
)
result
=
pipeline_result
(
link
,
current_user:
user
)
expect
(
result
[
:references
][
:user
]).
to
be_empty
...
...
@@ -60,14 +60,14 @@ describe Gitlab::Markdown::ReferenceGathererFilter do
group
=
create
(
:group
)
group
.
add_developer
(
user
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
Gitlab
::
Markdown
::
UserReferenceFilter
.
name
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
'UserReferenceFilter'
)
result
=
pipeline_result
(
link
,
current_user:
user
)
expect
(
result
[
:references
][
:user
]).
to
eq
([
user
])
end
it
'handles invalid Group references'
do
link
=
reference_link
(
group:
12345
,
reference_filter:
Gitlab
::
Markdown
::
UserReferenceFilter
.
name
)
link
=
reference_link
(
group:
12345
,
reference_filter:
'UserReferenceFilter'
)
expect
{
pipeline_result
(
link
)
}.
not_to
raise_error
end
...
...
@@ -77,7 +77,7 @@ describe Gitlab::Markdown::ReferenceGathererFilter do
it
'allows any User reference'
do
user
=
create
(
:user
)
link
=
reference_link
(
user:
user
.
id
,
reference_filter:
Gitlab
::
Markdown
::
UserReferenceFilter
.
name
)
link
=
reference_link
(
user:
user
.
id
,
reference_filter:
'UserReferenceFilter'
)
result
=
pipeline_result
(
link
)
expect
(
result
[
:references
][
:user
]).
to
eq
([
user
])
...
...
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