Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion problem_builder/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ def table_render(self, data, suffix=''):
for child_id in self.children:
child = self.runtime.get_block(child_id)
# Child should be an instance of MentoringTableColumn
header_values.append(child.header)
header = child.header
# Make sure /jump_to_id/ URLs are expanded correctly
if getattr(self.runtime, 'replace_jump_to_id_urls', None):
header = self.runtime.replace_jump_to_id_urls(header)
header_values.append(header)
child_frag = child.render('mentoring_view', context)
content_values.append(child_frag.content)
context['header_values'] = header_values if any(header_values) else None
Expand Down
15 changes: 15 additions & 0 deletions problem_builder/tests/integration/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

# Imports ###########################################################

from mock import patch
from workbench.runtime import WorkbenchRuntime
from .base_test import MentoringBaseTest


Expand Down Expand Up @@ -54,3 +56,16 @@ def test_mentoring_table(self):
self.assertEqual(len(rows), 2)
self.assertEqual(rows[0].text, 'This is the answer #1')
self.assertEqual(rows[1].text, 'This is the answer #2')

# Ensure that table block makes an effort to translate URLs in column headers
link_template = "<a href='http://www.test.com'>{}</a> in a column header."
original_contents = link_template.format('Link')
updated_contents = link_template.format('Updated link')

with patch.object(WorkbenchRuntime, 'replace_jump_to_id_urls', create=True) as patched_method:
patched_method.return_value = updated_contents

table = self.go_to_page('Table 3', css_selector='.mentoring-table')
patched_method.assert_called_once_with(original_contents)
link = table.find_element_by_css_selector('a')
self.assertEquals(link.text, 'Updated link')
9 changes: 9 additions & 0 deletions problem_builder/tests/integration/xml/table_3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vertical_demo>
<problem-builder display_submit="false" enforce_dependency="false">
<pb-table>
<pb-column header="&lt;a href='http://www.test.com'&gt;Link&lt;/a&gt; in a column header.">
<pb-answer-recap name="table_3_answer_1"/>
</pb-column>
</pb-table>
</problem-builder>
</vertical_demo>