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.
This commit is contained in:
@@ -2,19 +2,31 @@
|
|||||||
<%= render "posts/partials/index/blacklist" %>
|
<%= render "posts/partials/index/blacklist" %>
|
||||||
<%= render "wiki_pages/recent_changes" %>
|
<%= render "wiki_pages/recent_changes" %>
|
||||||
|
|
||||||
<% if @wiki_page.present? %>
|
<% if @wiki_page.present? && !@wiki_page.new_record? %>
|
||||||
<h2>Options</h2>
|
<h2>Options</h2>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<% unless @wiki_page.is_meta_wiki? %>
|
<% unless @wiki_page.is_meta_wiki? %>
|
||||||
<li><%= link_to "Tag History", tag_versions_path(search: { tag_id: @wiki_page.tag.id }) %></li>
|
<% if @wiki_page.tag.present? %>
|
||||||
<li><%= link_to "Post History", post_versions_path(search: { changed_tags: @wiki_page.title }) %></li>
|
<li><%= link_to "Tag History", tag_versions_path(search: { tag_id: @wiki_page.tag&.id }) %></li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if @wiki_page.title.present? %>
|
||||||
|
<li><%= link_to "Post History", post_versions_path(search: { changed_tags: @wiki_page.title }) %></li>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li><%= link_to "Wiki History", wiki_page_versions_path(search: { wiki_page_id: @wiki_page.id }) %></li>
|
|
||||||
<% if Danbooru.config.forum_enabled?.to_s.truthy? %>
|
<% if @wiki_page.id.present? %>
|
||||||
|
<li><%= link_to "Wiki History", wiki_page_versions_path(search: { wiki_page_id: @wiki_page.id }) %></li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if Danbooru.config.forum_enabled?.to_s.truthy? && @wiki_page.title.present? %>
|
||||||
<li><%= link_to "Discussions", forum_posts_path(search: { linked_to: @wiki_page.title }) %></li>
|
<li><%= link_to "Discussions", forum_posts_path(search: { linked_to: @wiki_page.title }) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li><%= link_to "What Links Here", wiki_pages_path(search: { linked_to: @wiki_page.title }) %></li>
|
|
||||||
|
<% if @wiki_page.title.present? %>
|
||||||
|
<li><%= link_to "What Links Here", wiki_pages_path(search: { linked_to: @wiki_page.title }) %></li>
|
||||||
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -97,6 +97,14 @@ class WikiPagesControllerTest < ActionDispatch::IntegrationTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
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
|
should "show the 'does not exist' page for a nonexistent title" do
|
||||||
get wiki_page_path("what")
|
get wiki_page_path("what")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user