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
Jérome Perrin
gitlab-ce
Commits
567b8a99
Commit
567b8a99
authored
Nov 21, 2016
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update gitlab flavored markdown tests to reflect namespaced ids
parent
94ae12f6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
12 deletions
+17
-12
features/steps/shared/markdown.rb
features/steps/shared/markdown.rb
+1
-1
spec/lib/banzai/filter/table_of_contents_filter_spec.rb
spec/lib/banzai/filter/table_of_contents_filter_spec.rb
+13
-8
spec/support/matchers/markdown_matchers.rb
spec/support/matchers/markdown_matchers.rb
+3
-3
No files found.
features/steps/shared/markdown.rb
View file @
567b8a99
...
@@ -2,7 +2,7 @@ module SharedMarkdown
...
@@ -2,7 +2,7 @@ module SharedMarkdown
include
Spinach
::
DSL
include
Spinach
::
DSL
def
header_should_have_correct_id_and_link
(
level
,
text
,
id
,
parent
=
".wiki"
)
def
header_should_have_correct_id_and_link
(
level
,
text
,
id
,
parent
=
".wiki"
)
node
=
find
(
"
#{
parent
}
h
#{
level
}
a#
#{
id
}
"
)
node
=
find
(
"
#{
parent
}
h
#{
level
}
a#
user-content_
#{
id
}
"
)
expect
(
node
[
:href
]).
to
eq
"#
#{
id
}
"
expect
(
node
[
:href
]).
to
eq
"#
#{
id
}
"
# Work around a weird Capybara behavior where calling `parent` on a node
# Work around a weird Capybara behavior where calling `parent` on a node
...
...
spec/lib/banzai/filter/table_of_contents_filter_spec.rb
View file @
567b8a99
...
@@ -22,7 +22,7 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do
...
@@ -22,7 +22,7 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do
html
=
header
(
i
,
"Header
#{
i
}
"
)
html
=
header
(
i
,
"Header
#{
i
}
"
)
doc
=
filter
(
html
)
doc
=
filter
(
html
)
expect
(
doc
.
css
(
"h
#{
i
}
a"
).
first
.
attr
(
'id'
)).
to
eq
"header-
#{
i
}
"
expect
(
doc
.
css
(
"h
#{
i
}
a"
).
first
.
attr
(
'id'
)).
to
eq
"
user-content_
header-
#{
i
}
"
end
end
end
end
...
@@ -32,7 +32,12 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do
...
@@ -32,7 +32,12 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'class'
)).
to
eq
'anchor'
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'class'
)).
to
eq
'anchor'
end
end
it
'links to the id'
do
it
'has a namespaced id'
do
doc
=
filter
(
header
(
1
,
'Header'
))
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'id'
)).
to
eq
'user-content_header'
end
it
'links to the non-namespaced id'
do
doc
=
filter
(
header
(
1
,
'Header'
))
doc
=
filter
(
header
(
1
,
'Header'
))
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'href'
)).
to
eq
'#header'
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'href'
)).
to
eq
'#header'
end
end
...
@@ -40,29 +45,29 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do
...
@@ -40,29 +45,29 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do
describe
'generated IDs'
do
describe
'generated IDs'
do
it
'translates spaces to dashes'
do
it
'translates spaces to dashes'
do
doc
=
filter
(
header
(
1
,
'This header has spaces in it'
))
doc
=
filter
(
header
(
1
,
'This header has spaces in it'
))
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'
id'
)).
to
eq
'
this-header-has-spaces-in-it'
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'
href'
)).
to
eq
'#
this-header-has-spaces-in-it'
end
end
it
'squeezes multiple spaces and dashes'
do
it
'squeezes multiple spaces and dashes'
do
doc
=
filter
(
header
(
1
,
'This---header is poorly-formatted'
))
doc
=
filter
(
header
(
1
,
'This---header is poorly-formatted'
))
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'
id'
)).
to
eq
'
this-header-is-poorly-formatted'
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'
href'
)).
to
eq
'#
this-header-is-poorly-formatted'
end
end
it
'removes punctuation'
do
it
'removes punctuation'
do
doc
=
filter
(
header
(
1
,
"This, header! is, filled. with @ punctuation?"
))
doc
=
filter
(
header
(
1
,
"This, header! is, filled. with @ punctuation?"
))
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'
id'
)).
to
eq
'
this-header-is-filled-with-punctuation'
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'
href'
)).
to
eq
'#
this-header-is-filled-with-punctuation'
end
end
it
'appends a unique number to duplicates'
do
it
'appends a unique number to duplicates'
do
doc
=
filter
(
header
(
1
,
'One'
)
+
header
(
2
,
'One'
))
doc
=
filter
(
header
(
1
,
'One'
)
+
header
(
2
,
'One'
))
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'
id'
)).
to
eq
'
one'
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'
href'
)).
to
eq
'#
one'
expect
(
doc
.
css
(
'h2 a'
).
first
.
attr
(
'
id'
)).
to
eq
'
one-1'
expect
(
doc
.
css
(
'h2 a'
).
first
.
attr
(
'
href'
)).
to
eq
'#
one-1'
end
end
it
'supports Unicode'
do
it
'supports Unicode'
do
doc
=
filter
(
header
(
1
,
'한글'
))
doc
=
filter
(
header
(
1
,
'한글'
))
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'id'
)).
to
eq
'한글'
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'id'
)).
to
eq
'
user-content_
한글'
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'href'
)).
to
eq
'#한글'
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'href'
)).
to
eq
'#한글'
end
end
end
end
...
...
spec/support/matchers/markdown_matchers.rb
View file @
567b8a99
...
@@ -38,9 +38,9 @@ module MarkdownMatchers
...
@@ -38,9 +38,9 @@ module MarkdownMatchers
set_default_markdown_messages
set_default_markdown_messages
match
do
|
actual
|
match
do
|
actual
|
expect
(
actual
).
to
have_selector
(
'h1 a#gitlab-markdown'
)
expect
(
actual
).
to
have_selector
(
'h1 a#
user-content_
gitlab-markdown'
)
expect
(
actual
).
to
have_selector
(
'h2 a#markdown'
)
expect
(
actual
).
to
have_selector
(
'h2 a#
user-content_
markdown'
)
expect
(
actual
).
to
have_selector
(
'h3 a#autolinkfilter'
)
expect
(
actual
).
to
have_selector
(
'h3 a#
user-content_
autolinkfilter'
)
end
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