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
e0601537
Commit
e0601537
authored
Mar 29, 2017
by
blackst0ne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make user mentions case-insensitive
parent
ad831ace
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
changelogs/unreleased/make_user_mentions_case_insensitive.yml
...gelogs/unreleased/make_user_mentions_case_insensitive.yml
+4
-0
lib/banzai/filter/user_reference_filter.rb
lib/banzai/filter/user_reference_filter.rb
+2
-2
spec/lib/banzai/filter/user_reference_filter_spec.rb
spec/lib/banzai/filter/user_reference_filter_spec.rb
+8
-0
No files found.
changelogs/unreleased/make_user_mentions_case_insensitive.yml
0 → 100644
View file @
e0601537
---
title
:
Make user mentions case-insensitive
merge_request
:
10285
author
:
blackst0ne
lib/banzai/filter/user_reference_filter.rb
View file @
e0601537
...
@@ -60,7 +60,7 @@ module Banzai
...
@@ -60,7 +60,7 @@ module Banzai
self
.
class
.
references_in
(
text
)
do
|
match
,
username
|
self
.
class
.
references_in
(
text
)
do
|
match
,
username
|
if
username
==
'all'
&&
!
skip_project_check?
if
username
==
'all'
&&
!
skip_project_check?
link_to_all
(
link_content:
link_content
)
link_to_all
(
link_content:
link_content
)
elsif
namespace
=
namespaces
[
username
]
elsif
namespace
=
namespaces
[
username
.
downcase
]
link_to_namespace
(
namespace
,
link_content:
link_content
)
||
match
link_to_namespace
(
namespace
,
link_content:
link_content
)
||
match
else
else
match
match
...
@@ -74,7 +74,7 @@ module Banzai
...
@@ -74,7 +74,7 @@ module Banzai
# The keys of this Hash are the namespace paths, the values the
# The keys of this Hash are the namespace paths, the values the
# corresponding Namespace objects.
# corresponding Namespace objects.
def
namespaces
def
namespaces
@namespaces
||=
Namespace
.
where_full_path_in
(
usernames
).
index_by
(
&
:full_path
)
@namespaces
||=
Namespace
.
where_full_path_in
(
usernames
).
index_by
(
&
:full_path
)
.
transform_keys
(
&
:downcase
)
end
end
# Returns all usernames referenced in the current document.
# Returns all usernames referenced in the current document.
...
...
spec/lib/banzai/filter/user_reference_filter_spec.rb
View file @
e0601537
...
@@ -83,6 +83,14 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do
...
@@ -83,6 +83,14 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
1
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
1
end
end
it
'links to a User with different case-sensitivity'
do
user
=
create
(
:user
,
username:
'RescueRanger'
)
doc
=
reference_filter
(
"Hey
#{
user
.
to_reference
.
upcase
}
"
)
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
1
expect
(
doc
.
css
(
'a'
).
text
).
to
eq
(
user
.
to_reference
)
end
it
'includes a data-user attribute'
do
it
'includes a data-user attribute'
do
doc
=
reference_filter
(
"Hey
#{
reference
}
"
)
doc
=
reference_filter
(
"Hey
#{
reference
}
"
)
link
=
doc
.
css
(
'a'
).
first
link
=
doc
.
css
(
'a'
).
first
...
...
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