From 0267e4e3d761f3cab8d5fb3b373c41e9742aebef Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 12 Sep 2022 21:16:52 -0500 Subject: [PATCH] wikis: fix exception when wiki doesn't have a tag. Fix a nil reference exception in the sidebar when a wiki page doesn't belong to a tag. Also hide the options sidebar on the new wiki page since none of the options are relevant when creating a new wiki. --- app/views/wiki_pages/_sidebar.html.erb | 24 ++++++++++++++----- test/functional/wiki_pages_controller_test.rb | 8 +++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/views/wiki_pages/_sidebar.html.erb b/app/views/wiki_pages/_sidebar.html.erb index f846b6300..3640570ab 100644 --- a/app/views/wiki_pages/_sidebar.html.erb +++ b/app/views/wiki_pages/_sidebar.html.erb @@ -2,19 +2,31 @@ <%= render "posts/partials/index/blacklist" %> <%= render "wiki_pages/recent_changes" %> - <% if @wiki_page.present? %> + <% if @wiki_page.present? && !@wiki_page.new_record? %>

Options

<% end %> <% end %> diff --git a/test/functional/wiki_pages_controller_test.rb b/test/functional/wiki_pages_controller_test.rb index 3fdeb990b..7bd57cb2f 100644 --- a/test/functional/wiki_pages_controller_test.rb +++ b/test/functional/wiki_pages_controller_test.rb @@ -97,6 +97,14 @@ class WikiPagesControllerTest < ActionDispatch::IntegrationTest assert_response :success end + should "render for a wiki without a tag" do + @wiki_page = create(:wiki_page, title: "help:foo") + get wiki_page_path(@wiki_page) + + assert(@wiki_page.tag.nil?) + assert_response :success + end + should "show the 'does not exist' page for a nonexistent title" do get wiki_page_path("what")