summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-10 00:44:22 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-10 00:44:22 +0200
commitcdf861a23233afb955b3c722a73d9e6ac8de3942 (patch)
tree4330e1ada833d4e41afaf4dd9d67d3a0effe1a13
parenta25d90335ad3738b6831288190132c2f7498465c (diff)
Fix stale assertions and escaped body in revisions#show
The table-based markup revisions#show's own test was asserting against (<strong>, <td>) was retired when this view moved to the node_description/node_content pattern; updated the assertions to match. Found in the same pass: @page.body had no raw(), so any real markup in a revision's body rendered as escaped entities on this page — same bug class as revisions#diff, just not yet fixed here.
-rw-r--r--app/views/revisions/show.html.erb2
-rw-r--r--test/controllers/revisions_controller_test.rb24
2 files changed, 19 insertions, 7 deletions
diff --git a/app/views/revisions/show.html.erb b/app/views/revisions/show.html.erb
index 4148096..92d959b 100644
--- a/app/views/revisions/show.html.erb
+++ b/app/views/revisions/show.html.erb
@@ -33,6 +33,6 @@
33 <div class="node_content"><%= @page.abstract %></div> 33 <div class="node_content"><%= @page.abstract %></div>
34 34
35 <div class="node_description">Body</div> 35 <div class="node_description">Body</div>
36 <div class="node_content"><%= @page.body %></div> 36 <div class="node_content"><%= raw @page.body %></div>
37 </div> 37 </div>
38</div> 38</div>
diff --git a/test/controllers/revisions_controller_test.rb b/test/controllers/revisions_controller_test.rb
index e2fc976..46fc220 100644
--- a/test/controllers/revisions_controller_test.rb
+++ b/test/controllers/revisions_controller_test.rb
@@ -28,21 +28,33 @@ class RevisionsControllerTest < ActionController::TestCase
28 assert_response :success 28 assert_response :success
29 assert_select ".revision", 2 29 assert_select ".revision", 2
30 end 30 end
31 31
32 test "showing one revision" do 32 test "showing one revision" do
33 login_as :quentin 33 login_as :quentin
34 get :show, params: { :node_id => @node.id, :id => @node.pages.last.id } 34 get :show, params: { :node_id => @node.id, :id => @node.pages.last.id }
35 assert_response :success 35 assert_response :success
36 assert_select "strong", "Body" 36 assert_select ".node_description", "Body"
37 assert_select "td", {:count => 1, :text => "second"} 37 assert_select ".node_content", {:count => 1, :text => "second"}
38 end 38 end
39 39
40 test "showing a revision renders real markup in the body, not escaped entities" do
41 login_as :quentin
42 node = Node.root.children.create!(:slug => "show_markup_test")
43 draft = node.draft
44 draft.body = "<h3>Hello</h3>"
45 node.publish_draft!
46
47 get :show, params: { :node_id => node.id, :id => node.head.id }
48 assert_response :success
49 assert_select ".node_content h3", "Hello"
50 end
51
40 test "diffing two revisions" do 52 test "diffing two revisions" do
41 login_as :quentin 53 login_as :quentin
42 post( 54 post(
43 :diff, params: { 55 :diff, params: {
44 :node_id => @node.id, 56 :node_id => @node.id,
45 :start_revision => @node.pages.first.revision, 57 :start_revision => @node.pages.first.revision,
46 :end_revision => @node.pages.last.revision 58 :end_revision => @node.pages.last.revision
47 } 59 }
48 ) 60 )