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
Léo-Paul Géneau
gitlab-ce
Commits
3a0b4340
Commit
3a0b4340
authored
Apr 16, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more tests for cross-project references
parent
34f1dbb1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
139 additions
and
84 deletions
+139
-84
spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb
...lib/gitlab/markdown/commit_range_reference_filter_spec.rb
+26
-17
spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
+24
-15
spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
+30
-21
spec/lib/gitlab/markdown/merge_request_reference_filter_spec.rb
...ib/gitlab/markdown/merge_request_reference_filter_spec.rb
+25
-16
spec/lib/gitlab/markdown/snippet_reference_filter_spec.rb
spec/lib/gitlab/markdown/snippet_reference_filter_spec.rb
+24
-15
spec/support/reference_filter_spec_helper.rb
spec/support/reference_filter_spec_helper.rb
+10
-0
No files found.
spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb
View file @
3a0b4340
...
@@ -90,10 +90,8 @@ module Gitlab::Markdown
...
@@ -90,10 +90,8 @@ module Gitlab::Markdown
let
(
:commit2
)
{
project
.
repository
.
commit
(
"HEAD~2"
)
}
let
(
:commit2
)
{
project
.
repository
.
commit
(
"HEAD~2"
)
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
@
#{
commit1
.
id
}
...
#{
commit2
.
id
}
"
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
@
#{
commit1
.
id
}
...
#{
commit2
.
id
}
"
}
before
do
context
'when user can access reference'
do
allow_any_instance_of
(
described_class
).
before
{
allow_cross_reference!
}
to
receive
(
:user_can_reference_project?
).
and_return
(
true
)
end
it
'links to a valid reference'
do
it
'links to a valid reference'
do
doc
=
filter
(
"See
#{
reference
}
"
)
doc
=
filter
(
"See
#{
reference
}
"
)
...
@@ -115,5 +113,16 @@ module Gitlab::Markdown
...
@@ -115,5 +113,16 @@ module Gitlab::Markdown
expect
(
filter
(
act
).
to_html
).
to
eq
exp
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
end
end
end
context
'when user cannot access reference'
do
before
{
disallow_cross_reference!
}
it
'ignores valid references'
do
exp
=
act
=
"See
#{
reference
}
"
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
end
end
end
end
end
end
spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
View file @
3a0b4340
...
@@ -83,10 +83,8 @@ module Gitlab::Markdown
...
@@ -83,10 +83,8 @@ module Gitlab::Markdown
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
@
#{
commit
.
id
}
"
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
@
#{
commit
.
id
}
"
}
before
do
context
'when user can access reference'
do
allow_any_instance_of
(
described_class
).
before
{
allow_cross_reference!
}
to
receive
(
:user_can_reference_project?
).
and_return
(
true
)
end
it
'links to a valid reference'
do
it
'links to a valid reference'
do
doc
=
filter
(
"See
#{
reference
}
"
)
doc
=
filter
(
"See
#{
reference
}
"
)
...
@@ -105,5 +103,16 @@ module Gitlab::Markdown
...
@@ -105,5 +103,16 @@ module Gitlab::Markdown
expect
(
filter
(
act
).
to_html
).
to
eq
exp
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
end
end
end
context
'when user cannot access reference'
do
before
{
disallow_cross_reference!
}
it
'ignores valid references'
do
exp
=
act
=
"See
#{
reference
}
"
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
end
end
end
end
end
end
spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
View file @
3a0b4340
...
@@ -89,10 +89,8 @@ module Gitlab::Markdown
...
@@ -89,10 +89,8 @@ module Gitlab::Markdown
let
(
:issue
)
{
create
(
:issue
,
project:
project2
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project2
)
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
#
#{
issue
.
iid
}
"
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
#
#{
issue
.
iid
}
"
}
before
do
context
'when user can access reference'
do
allow_any_instance_of
(
described_class
).
before
{
allow_cross_reference!
}
to
receive
(
:user_can_reference_project?
).
and_return
(
true
)
end
it
'ignores valid references when cross-reference project uses external tracker'
do
it
'ignores valid references when cross-reference project uses external tracker'
do
expect_any_instance_of
(
Project
).
to
receive
(
:issue_exists?
).
expect_any_instance_of
(
Project
).
to
receive
(
:issue_exists?
).
...
@@ -120,5 +118,16 @@ module Gitlab::Markdown
...
@@ -120,5 +118,16 @@ module Gitlab::Markdown
expect
(
filter
(
act
).
to_html
).
to
eq
exp
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
end
end
end
context
'when user cannot access reference'
do
before
{
disallow_cross_reference!
}
it
'ignores valid references'
do
exp
=
act
=
"See
#{
reference
}
"
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
end
end
end
end
end
end
spec/lib/gitlab/markdown/merge_request_reference_filter_spec.rb
View file @
3a0b4340
...
@@ -77,10 +77,8 @@ module Gitlab::Markdown
...
@@ -77,10 +77,8 @@ module Gitlab::Markdown
let
(
:merge
)
{
create
(
:merge_request
,
source_project:
project2
)
}
let
(
:merge
)
{
create
(
:merge_request
,
source_project:
project2
)
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
!
#{
merge
.
iid
}
"
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
!
#{
merge
.
iid
}
"
}
before
do
context
'when user can access reference'
do
allow_any_instance_of
(
described_class
).
before
{
allow_cross_reference!
}
to
receive
(
:user_can_reference_project?
).
and_return
(
true
)
end
it
'links to a valid reference'
do
it
'links to a valid reference'
do
doc
=
filter
(
"See
#{
reference
}
"
)
doc
=
filter
(
"See
#{
reference
}
"
)
...
@@ -101,5 +99,16 @@ module Gitlab::Markdown
...
@@ -101,5 +99,16 @@ module Gitlab::Markdown
expect
(
filter
(
act
).
to_html
).
to
eq
exp
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
end
end
end
context
'when user cannot access reference'
do
before
{
disallow_cross_reference!
}
it
'ignores valid references'
do
exp
=
act
=
"See
#{
reference
}
"
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
end
end
end
end
end
end
spec/lib/gitlab/markdown/snippet_reference_filter_spec.rb
View file @
3a0b4340
...
@@ -76,10 +76,8 @@ module Gitlab::Markdown
...
@@ -76,10 +76,8 @@ module Gitlab::Markdown
let
(
:snippet
)
{
create
(
:project_snippet
,
project:
project2
)
}
let
(
:snippet
)
{
create
(
:project_snippet
,
project:
project2
)
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
$
#{
snippet
.
id
}
"
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
$
#{
snippet
.
id
}
"
}
before
do
context
'when user can access reference'
do
allow_any_instance_of
(
described_class
).
before
{
allow_cross_reference!
}
to
receive
(
:user_can_reference_project?
).
and_return
(
true
)
end
it
'links to a valid reference'
do
it
'links to a valid reference'
do
doc
=
filter
(
"See
#{
reference
}
"
)
doc
=
filter
(
"See
#{
reference
}
"
)
...
@@ -99,5 +97,16 @@ module Gitlab::Markdown
...
@@ -99,5 +97,16 @@ module Gitlab::Markdown
expect
(
filter
(
act
).
to_html
).
to
eq
exp
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
end
end
end
context
'when user cannot access reference'
do
before
{
disallow_cross_reference!
}
it
'ignores valid references'
do
exp
=
act
=
"See
#{
reference
}
"
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
end
end
end
end
end
end
spec/support/reference_filter_spec_helper.rb
View file @
3a0b4340
...
@@ -34,4 +34,14 @@ module ReferenceFilterSpecHelper
...
@@ -34,4 +34,14 @@ module ReferenceFilterSpecHelper
contexts
.
reverse_merge!
(
project:
project
)
contexts
.
reverse_merge!
(
project:
project
)
described_class
.
call
(
html
,
contexts
)
described_class
.
call
(
html
,
contexts
)
end
end
def
allow_cross_reference!
allow_any_instance_of
(
described_class
).
to
receive
(
:user_can_reference_project?
).
and_return
(
true
)
end
def
disallow_cross_reference!
allow_any_instance_of
(
described_class
).
to
receive
(
:user_can_reference_project?
).
and_return
(
false
)
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