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
54da8aa0
Commit
54da8aa0
authored
Jan 15, 2020
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the ability to handle link references
parent
6772427a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
13 deletions
+47
-13
ee/spec/lib/banzai/filter/design_reference_filter_spec.rb
ee/spec/lib/banzai/filter/design_reference_filter_spec.rb
+41
-12
ee/spec/support/helpers/design_management_test_helpers.rb
ee/spec/support/helpers/design_management_test_helpers.rb
+6
-1
No files found.
ee/spec/lib/banzai/filter/design_reference_filter_spec.rb
View file @
54da8aa0
...
...
@@ -43,6 +43,22 @@ describe Banzai::Filter::DesignReferenceFilter do
end
end
shared_examples
'a good link reference'
do
let
(
:link
)
{
doc
.
css
(
'a'
).
first
}
let
(
:href
)
{
path_for_design
(
design
)
}
let
(
:title
)
{
design
.
filename
}
it
'produces a good link'
,
:aggregate_failures
do
expect
(
link
.
attr
(
'href'
)).
to
eq
(
href
)
expect
(
link
.
attr
(
'title'
)).
to
eq
(
title
)
expect
(
link
.
attr
(
'class'
)).
to
eq
(
'gfm gfm-design has-tooltip'
)
expect
(
link
.
attr
(
'data-project'
)).
to
eq
(
project
.
id
.
to_s
)
expect
(
link
.
attr
(
'data-issue'
)).
to
eq
(
issue
.
id
.
to_s
)
expect
(
link
.
attr
(
'data-original'
)).
to
eq
(
reference
)
expect
(
link
.
text
).
to
eq
(
design
.
to_reference
)
end
end
describe
'.call'
do
it
'requires project context'
do
expect
{
described_class
.
call
(
''
)
}.
to
raise_error
(
ArgumentError
,
/:project/
)
...
...
@@ -151,7 +167,7 @@ describe Banzai::Filter::DesignReferenceFilter do
it
'links to the design'
do
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
))
.
to
eq
url
_for_design
(
design
)
.
to
eq
path
_for_design
(
design
)
end
end
...
...
@@ -166,16 +182,7 @@ describe Banzai::Filter::DesignReferenceFilter do
end
context
'the user has permission'
do
it
'produces a good link'
,
:aggregate_failures
do
link
=
doc
.
css
(
'a'
).
first
expect
(
link
.
attr
(
'href'
)).
to
eq
(
url_for_design
(
design
))
expect
(
link
.
attr
(
'title'
)).
to
eq
(
design
.
filename
)
expect
(
link
.
attr
(
'class'
)).
to
eq
(
'gfm gfm-design has-tooltip'
)
expect
(
link
.
attr
(
'data-project'
)).
to
eq
(
project
.
id
.
to_s
)
expect
(
link
.
attr
(
'data-issue'
)).
to
eq
(
issue
.
id
.
to_s
)
expect
(
link
.
attr
(
'data-original'
)).
to
eq
(
reference
)
end
it_behaves_like
'a good link reference'
end
context
'the filename needs to be escaped'
do
...
...
@@ -206,6 +213,28 @@ describe Banzai::Filter::DesignReferenceFilter do
end
end
context
'URL reference'
do
let
(
:reference
)
{
url_for_design
(
design
)
}
it
'matches the link_reference_pattern'
do
expect
(
reference
).
to
match
(
DesignManagement
::
Design
.
link_reference_pattern
)
end
it
'constructs the appropriate references_per_parent structure'
do
filter
=
filter_instance
filter
.
call
expect
(
filter
.
references_per_parent
).
to
eq
({
project
.
full_path
=>
[
filter
.
record_identifier
(
design
)].
to_set
})
end
it_behaves_like
'a good link reference'
do
let
(
:href
)
{
reference
}
end
end
context
'cross-project / cross-namespace complete reference'
do
let
(
:reference
)
{
x_project_design
.
to_reference
(
project
)
}
...
...
@@ -213,7 +242,7 @@ describe Banzai::Filter::DesignReferenceFilter do
it
'links to a valid reference'
do
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
))
.
to
eq
url
_for_design
(
x_project_design
)
.
to
eq
path
_for_design
(
x_project_design
)
end
context
'the current user does not have access to that project'
do
...
...
ee/spec/support/helpers/design_management_test_helpers.rb
View file @
54da8aa0
...
...
@@ -19,11 +19,16 @@ module DesignManagementTestHelpers
act_on_designs
(
designs
)
{
::
DesignManagement
::
Action
.
modification
}
end
def
url
_for_design
(
design
)
def
path
_for_design
(
design
)
path_options
=
{
vueroute:
design
.
filename
}
Gitlab
::
Routing
.
url_helpers
.
designs_project_issue_path
(
design
.
project
,
design
.
issue
,
path_options
)
end
def
url_for_design
(
design
)
path_options
=
{
vueroute:
design
.
filename
}
Gitlab
::
Routing
.
url_helpers
.
designs_project_issue_url
(
design
.
project
,
design
.
issue
,
path_options
)
end
private
def
act_on_designs
(
designs
,
&
block
)
...
...
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