From a28a58c1f6b6df70e9539af3bf2730f028221669 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 12 Aug 2019 13:38:45 -0500 Subject: [PATCH] tests: add more posts/index controller tests. --- test/functional/posts_controller_test.rb | 48 +++++++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb index 283fa3303..0952bdcfa 100644 --- a/test/functional/posts_controller_test.rb +++ b/test/functional/posts_controller_test.rb @@ -76,9 +76,53 @@ class PostsControllerTest < ActionDispatch::IntegrationTest assert_response :success end - context "with a search" do + context "with a single tag search" do + should "render for an empty tag" do + get posts_path, params: { tags: "does_not_exist" } + assert_response :success + end + + should "render for an artist tag" do + create(:post, tag_string: "artist:bkub") + get posts_path, params: { tags: "bkub" } + assert_response :success + + artist = create(:artist, name: "bkub") + get posts_path, params: { tags: "bkub" } + assert_response :success + + artist.update(is_banned: true) + get posts_path, params: { tags: "bkub" } + assert_response :success + + artist.update(is_banned: false, is_active: false) + get posts_path, params: { tags: "bkub" } + assert_response :success + + as_user { create(:wiki_page, title: "bkub") } + get posts_path, params: { tags: "bkub" } + assert_response :success + end + + should "render for a tag with a wiki page" do + create(:post, tag_string: "char:fumimi") + get posts_path, params: { tags: "fumimi" } + assert_response :success + + as_user { @wiki = create(:wiki_page, title: "fumimi") } + get posts_path, params: { tags: "fumimi" } + assert_response :success + + as_user { @wiki.update(is_deleted: true) } + get posts_path, params: { tags: "bkub" } + assert_response :success + end + end + + context "with a multi-tag search" do should "render" do - get posts_path, params: {:tags => "aaaa"} + create(:post, tag_string: "1girl solo") + get posts_path, params: {:tags => "1girl solo"} assert_response :success end end