| 1624 |
1624 |
end
|
| 1625 |
1625 |
end
|
|
1626 |
def test_section_edit_links_with_collapse_macro
|
|
1627 |
raw = <<~RAW
|
|
1628 |
# Wiki
|
|
1629 |
## Section A
|
|
1630 |
|
|
1631 |
collapsed section
|
|
1632 |
{{collapse(View details...)
|
|
1633 |
## Section B
|
|
1634 |
}}
|
|
1635 |
|
|
1636 |
## Section C
|
|
1637 |
RAW
|
|
1638 |
@project = Project.find(1)
|
|
1639 |
set_language_if_valid 'en'
|
|
1640 |
with_settings :text_formatting => 'common_mark' do
|
|
1641 |
result =
|
|
1642 |
textilizable(
|
|
1643 |
raw,
|
|
1644 |
:edit_section_links =>
|
|
1645 |
{:controller => 'wiki', :action => 'edit',
|
|
1646 |
:project_id => '1', :id => 'Test'}
|
|
1647 |
).delete("\n")
|
|
1648 |
|
|
1649 |
# Section B inside collapse macro should have section=3 edit link
|
|
1650 |
assert_match(
|
|
1651 |
Regexp.new(
|
|
1652 |
'<div class="contextual heading-2" title="Edit this section" id="section-3">' \
|
|
1653 |
'<a class="icon-only icon-edit" href="/projects/1/wiki/Test/edit\\?section=3">' \
|
|
1654 |
'<svg class="s18 icon-svg" aria-hidden="true"><use href="/assets/icons-.*\\.svg#icon--edit"></use></svg>' \
|
|
1655 |
'<span class="icon-label">Edit this section</span>' \
|
|
1656 |
'</a></div>' \
|
|
1657 |
'<a name="Section-B"></a>' \
|
|
1658 |
'<h2 >Section B<a href="#Section-B" class="wiki-anchor">¶</a></h2>'
|
|
1659 |
),
|
|
1660 |
result
|
|
1661 |
)
|
|
1662 |
|
|
1663 |
# Section C after collapse macro should have section=4 edit link
|
|
1664 |
assert_match(
|
|
1665 |
Regexp.new(
|
|
1666 |
'<div class="contextual heading-2" title="Edit this section" id="section-4">' \
|
|
1667 |
'<a class="icon-only icon-edit" href="/projects/1/wiki/Test/edit\\?section=4">' \
|
|
1668 |
'<svg class="s18 icon-svg" aria-hidden="true"><use href="/assets/icons-.*\\.svg#icon--edit"></use></svg>' \
|
|
1669 |
'<span class="icon-label">Edit this section</span>' \
|
|
1670 |
'</a></div>' \
|
|
1671 |
'<a name="Section-C"></a>' \
|
|
1672 |
'<h2 >Section C<a href="#Section-C" class="wiki-anchor">¶</a></h2>'
|
|
1673 |
),
|
|
1674 |
result
|
|
1675 |
)
|
|
1676 |
end
|
|
1677 |
end
|
|
1678 |
|
|
1679 |
|
| 1626 |
1680 |
def test_default_formatter
|
| 1627 |
1681 |
with_settings :text_formatting => 'unknown' do
|
| 1628 |
1682 |
text = 'a *link*: http://www.example.net/'
|