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
Kazuhiko Shiozaki
gitlab-ce
Commits
72afcbcd
Commit
72afcbcd
authored
Oct 07, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always allow references to the current project
parent
f42cfa9e
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
12 additions
and
8 deletions
+12
-8
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+0
-1
lib/gitlab/markdown/redactor_filter.rb
lib/gitlab/markdown/redactor_filter.rb
+1
-1
lib/gitlab/markdown/reference_filter.rb
lib/gitlab/markdown/reference_filter.rb
+5
-2
lib/gitlab/markdown/reference_gatherer_filter.rb
lib/gitlab/markdown/reference_gatherer_filter.rb
+1
-1
lib/gitlab/markdown/user_reference_filter.rb
lib/gitlab/markdown/user_reference_filter.rb
+1
-1
spec/lib/gitlab/reference_extractor_spec.rb
spec/lib/gitlab/reference_extractor_spec.rb
+2
-2
spec/support/mentionable_shared_examples.rb
spec/support/mentionable_shared_examples.rb
+2
-0
No files found.
app/models/concerns/mentionable.rb
View file @
72afcbcd
...
@@ -61,7 +61,6 @@ module Mentionable
...
@@ -61,7 +61,6 @@ module Mentionable
ext
=
Gitlab
::
ReferenceExtractor
.
new
(
p
,
current_user
)
ext
=
Gitlab
::
ReferenceExtractor
.
new
(
p
,
current_user
)
ext
.
analyze
(
text
)
ext
.
analyze
(
text
)
(
ext
.
issues
+
ext
.
merge_requests
+
ext
.
commits
).
uniq
-
[
local_reference
]
(
ext
.
issues
+
ext
.
merge_requests
+
ext
.
commits
).
uniq
-
[
local_reference
]
end
end
...
...
lib/gitlab/markdown/redactor_filter.rb
View file @
72afcbcd
...
@@ -26,7 +26,7 @@ module Gitlab
...
@@ -26,7 +26,7 @@ module Gitlab
reference_type
=
node
.
attr
(
'data-reference-filter'
)
reference_type
=
node
.
attr
(
'data-reference-filter'
)
reference_filter
=
reference_type
.
constantize
reference_filter
=
reference_type
.
constantize
reference_filter
.
user_can_reference?
(
current_user
,
node
)
reference_filter
.
user_can_reference?
(
current_user
,
node
,
context
)
else
else
true
true
end
end
...
...
lib/gitlab/markdown/reference_filter.rb
View file @
72afcbcd
...
@@ -15,9 +15,12 @@ module Gitlab
...
@@ -15,9 +15,12 @@ module Gitlab
# Results:
# Results:
# :references - A Hash of references that were found and replaced.
# :references - A Hash of references that were found and replaced.
class
ReferenceFilter
<
HTML
::
Pipeline
::
Filter
class
ReferenceFilter
<
HTML
::
Pipeline
::
Filter
def
self
.
user_can_reference?
(
user
,
node
)
def
self
.
user_can_reference?
(
user
,
node
,
context
)
if
node
.
has_attribute?
(
'data-project'
)
if
node
.
has_attribute?
(
'data-project'
)
project
=
Project
.
find
(
node
.
attr
(
'data-project'
))
rescue
nil
project_id
=
node
.
attr
(
'data-project'
).
to_i
return
true
if
project_id
==
context
[
:project
].
id
project
=
Project
.
find
(
project_id
)
rescue
nil
Ability
.
abilities
.
allowed?
(
user
,
:read_project
,
project
)
Ability
.
abilities
.
allowed?
(
user
,
:read_project
,
project
)
else
else
true
true
...
...
lib/gitlab/markdown/reference_gatherer_filter.rb
View file @
72afcbcd
...
@@ -31,7 +31,7 @@ module Gitlab
...
@@ -31,7 +31,7 @@ module Gitlab
reference_type
=
node
.
attr
(
'data-reference-filter'
)
reference_type
=
node
.
attr
(
'data-reference-filter'
)
reference_filter
=
reference_type
.
constantize
reference_filter
=
reference_type
.
constantize
return
unless
reference_filter
.
user_can_reference?
(
current_user
,
node
)
return
unless
reference_filter
.
user_can_reference?
(
current_user
,
node
,
context
)
references
=
reference_filter
.
referenced_by
(
node
)
references
=
reference_filter
.
referenced_by
(
node
)
return
unless
references
return
unless
references
...
...
lib/gitlab/markdown/user_reference_filter.rb
View file @
72afcbcd
...
@@ -42,7 +42,7 @@ module Gitlab
...
@@ -42,7 +42,7 @@ module Gitlab
end
end
end
end
def
self
.
user_can_reference?
(
user
,
node
)
def
self
.
user_can_reference?
(
user
,
node
,
context
)
if
node
.
has_attribute?
(
'data-group'
)
if
node
.
has_attribute?
(
'data-group'
)
group
=
Group
.
find
(
node
.
attr
(
'data-group'
))
rescue
nil
group
=
Group
.
find
(
node
.
attr
(
'data-group'
))
rescue
nil
Ability
.
abilities
.
allowed?
(
user
,
:read_group
,
group
)
Ability
.
abilities
.
allowed?
(
user
,
:read_group
,
group
)
...
...
spec/lib/gitlab/reference_extractor_spec.rb
View file @
72afcbcd
...
@@ -2,7 +2,7 @@ require 'spec_helper'
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
ReferenceExtractor
do
describe
Gitlab
::
ReferenceExtractor
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
subject
{
Gitlab
::
ReferenceExtractor
.
new
(
project
,
project
.
owne
r
)
}
subject
{
Gitlab
::
ReferenceExtractor
.
new
(
project
,
project
.
creato
r
)
}
it
'accesses valid user objects'
do
it
'accesses valid user objects'
do
@u_foo
=
create
(
:user
,
username:
'foo'
)
@u_foo
=
create
(
:user
,
username:
'foo'
)
...
@@ -102,7 +102,7 @@ describe Gitlab::ReferenceExtractor do
...
@@ -102,7 +102,7 @@ describe Gitlab::ReferenceExtractor do
let
(
:issue
)
{
create
(
:issue
,
project:
other_project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
other_project
)
}
before
do
before
do
other_project
.
team
<<
[
project
.
owne
r
,
:developer
]
other_project
.
team
<<
[
project
.
creato
r
,
:developer
]
end
end
it
'handles project issue references'
do
it
'handles project issue references'
do
...
...
spec/support/mentionable_shared_examples.rb
View file @
72afcbcd
...
@@ -50,6 +50,8 @@ def common_mentionable_setup
...
@@ -50,6 +50,8 @@ def common_mentionable_setup
}
}
extra_commits
.
each
{
|
c
|
commitmap
[
c
.
short_id
]
=
c
}
extra_commits
.
each
{
|
c
|
commitmap
[
c
.
short_id
]
=
c
}
allow
(
Project
).
to
receive
(
:find
).
and_call_original
allow
(
Project
).
to
receive
(
:find
).
with
(
project
.
id
.
to_s
).
and_return
(
project
)
allow
(
project
.
repository
).
to
receive
(
:commit
)
{
|
sha
|
commitmap
[
sha
]
}
allow
(
project
.
repository
).
to
receive
(
:commit
)
{
|
sha
|
commitmap
[
sha
]
}
set_mentionable_text
.
call
(
ref_string
)
set_mentionable_text
.
call
(
ref_string
)
...
...
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