From 26d54c1e371f8ad4cf0cf08190f0a86962fe936f Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 9 Feb 2022 01:10:35 -0600 Subject: [PATCH] artists: show "Artist" tab in searches for artists without artist entry. On the post index page, show the "Artist" tab instead of the "Wiki" tab when searching for an artist tag that doesn't have an artist entry. This way the user is prompted to create a new artist entry instead of a new wiki. --- app/views/posts/index.html.erb | 8 +++++++- test/functional/posts_controller_test.rb | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index 49509abb2..ead6fd86f 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -62,6 +62,8 @@ <% if @post_set.artist.present? %> <%= link_to "Artist", artist_path(@post_set.artist), id: "show-excerpt-link", class: "artist-excerpt-link" %> + <% elsif @post_set.tag&.artist? %> + <%= link_to "Artist", new_artist_path(artist: { name: @post_set.tag.name }), id: "show-excerpt-link", class: "artist-excerpt-link", rel: "nofollow" %> <% elsif @post_set.wiki_page.present? %> <%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), id: "show-excerpt-link", class: "wiki-excerpt-link" %> <% elsif @post_set.pool.present? %> @@ -158,6 +160,10 @@

The artist requested removal of this page.

<% elsif @post_set.artist.present? %> <%= render "artists/summary", artist: @post_set.artist %> + <% elsif @post_set.tag&.artist? %> +

There is no artist entry yet for the artist <%= link_to @post_set.tag.name, new_artist_path(artist: { name: @post_set.tag.name }), rel: "nofollow" %>. <%= link_to "Create new artist entry", new_artist_path(artist: { name: @post_set.tag.name }), rel: "nofollow" %>.

+ + <%= render "tag_relationships/alias_and_implication_list", tag: @post_set.tag %> <% elsif @post_set.wiki_page.present? %> <% @post_set.wiki_page.tap do |wiki_page| %>
@@ -198,7 +204,7 @@ Creator: <%= link_to_user @post_set.favgroup.creator %> <% elsif @post_set.has_blank_wiki? %> -

There is currently no wiki page for the tag <%= link_to_wiki @post_set.tag.pretty_name %>. You can <%= link_to "create one", new_wiki_page_path(wiki_page: { title: @post_set.tag.name }), rel: "nofollow" %>.

+

There is no wiki page yet for the tag <%= link_to_wiki @post_set.tag.pretty_name %>. <%= link_to "Create new wiki page", new_wiki_page_path(wiki_page: { title: @post_set.tag.name }), rel: "nofollow" %>.

<%= render "tag_relationships/alias_and_implication_list", tag: @post_set.tag %> <% end %> diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb index 92658e3a8..0125a09a6 100644 --- a/test/functional/posts_controller_test.rb +++ b/test/functional/posts_controller_test.rb @@ -93,7 +93,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest create(:post, tag_string: "artist:bkub", rating: "s") get posts_path, params: { tags: "bkub" } assert_response :success - assert_select "#show-excerpt-link", count: 1, text: "Wiki" + assert_select "#show-excerpt-link", count: 1, text: "Artist" artist = create(:artist, name: "bkub") get posts_path, params: { tags: "bkub" } @@ -110,13 +110,13 @@ class PostsControllerTest < ActionDispatch::IntegrationTest artist.update(is_banned: false, is_deleted: true) get posts_path, params: { tags: "bkub" } assert_response :success - assert_select "#show-excerpt-link", count: 1, text: "Wiki" + assert_select "#show-excerpt-link", count: 1, text: "Artist" as(@user) { create(:wiki_page, title: "bkub") } get posts_path, params: { tags: "bkub" } assert_response :success - assert_select "#show-excerpt-link", count: 1, text: "Wiki" - assert_select "#view-wiki-link", count: 1 + assert_select "#show-excerpt-link", count: 1, text: "Artist" + assert_select "#view-wiki-link", count: 0 assert_select "#view-artist-link", count: 0 end