Skip to content

Commit 68f1179

Browse files
committed
Fix for text None shown on /-/actions, closes #2599
1 parent 2125115 commit 68f1179

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

datasette/templates/debug_actions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h1>Registered actions</h1>
3131
<td><strong>{{ action.name }}</strong></td>
3232
<td>{% if action.abbr %}<code>{{ action.abbr }}</code>{% endif %}</td>
3333
<td>{{ action.description or "" }}</td>
34-
<td><code>{{ action.resource_class }}</code></td>
34+
<td>{% if action.resource_class %}<code>{{ action.resource_class }}</code>{% endif %}</td>
3535
<td>{% if action.takes_parent %}✓{% endif %}</td>
3636
<td>{% if action.takes_child %}✓{% endif %}</td>
3737
<td>{% if action.also_requires %}<code>{{ action.also_requires }}</code>{% endif %}</td>

tests/test_html.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,21 @@ async def test_actions_page(ds_client):
11941194
ds_client.ds.root_enabled = original_root_enabled
11951195

11961196

1197+
@pytest.mark.asyncio
1198+
async def test_actions_page_does_not_display_none_string(ds_client):
1199+
"""Ensure the Resource column doesn't display the string 'None' for null values."""
1200+
# https://github.com/simonw/datasette/issues/2599
1201+
original_root_enabled = ds_client.ds.root_enabled
1202+
try:
1203+
ds_client.ds.root_enabled = True
1204+
cookies = {"ds_actor": ds_client.actor_cookie({"id": "root"})}
1205+
response = await ds_client.get("/-/actions", cookies=cookies)
1206+
assert response.status_code == 200
1207+
assert "<code>None</code>" not in response.text
1208+
finally:
1209+
ds_client.ds.root_enabled = original_root_enabled
1210+
1211+
11971212
@pytest.mark.asyncio
11981213
async def test_permission_debug_tabs_with_query_string(ds_client):
11991214
"""Test that navigation tabs persist query strings across Check, Allowed, and Rules pages"""

0 commit comments

Comments
 (0)