diff --git a/test/factories/forum_topic_visit.rb b/test/factories/forum_topic_visit.rb index 1c4e910f4..76d3f5b5b 100644 --- a/test/factories/forum_topic_visit.rb +++ b/test/factories/forum_topic_visit.rb @@ -1,3 +1,6 @@ FactoryBot.define do - factory(:forum_topic_visit) + factory(:forum_topic_visit) do + user + forum_topic + end end diff --git a/test/factories/pixiv_ugoira_frame_data.rb b/test/factories/pixiv_ugoira_frame_data.rb new file mode 100644 index 000000000..2370db591 --- /dev/null +++ b/test/factories/pixiv_ugoira_frame_data.rb @@ -0,0 +1,12 @@ +FactoryBot.define do + factory(:pixiv_ugoira_frame_data) do + post + content_type { "image/jpeg" } + data do + [ + { "file" => "000000.jpg", "delay" => 200 }, + { "file" => "000001.jpg", "delay" => 200 }, + ] + end + end +end diff --git a/test/factories/post_appeal.rb b/test/factories/post_appeal.rb index 8bddbf093..db6912146 100644 --- a/test/factories/post_appeal.rb +++ b/test/factories/post_appeal.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory(:post_appeal) do creator - post + post { build(:post, is_deleted: true) } reason {"xxx"} end end diff --git a/test/functional/bulk_update_requests_controller_test.rb b/test/functional/bulk_update_requests_controller_test.rb index 5a256b622..e9f7f3dd3 100644 --- a/test/functional/bulk_update_requests_controller_test.rb +++ b/test/functional/bulk_update_requests_controller_test.rb @@ -10,7 +10,14 @@ class BulkUpdateRequestsControllerTest < ActionDispatch::IntegrationTest context "#new" do should "render" do - get_auth bulk_update_requests_path, @user + get_auth new_bulk_update_request_path, @user + assert_response :success + end + end + + context "#edit" do + should "render" do + get_auth edit_bulk_update_request_path(@bulk_update_request), @user assert_response :success end end diff --git a/test/functional/delayed_jobs_controller_test.rb b/test/functional/delayed_jobs_controller_test.rb index eefd2d996..beb60b69a 100644 --- a/test/functional/delayed_jobs_controller_test.rb +++ b/test/functional/delayed_jobs_controller_test.rb @@ -2,12 +2,44 @@ require 'test_helper' class DelayedJobsControllerTest < ActionDispatch::IntegrationTest context "The delayed jobs controller" do + setup do + @user = create(:admin_user) + @job = create(:delayed_job) + end + context "index action" do should "render" do - create(:delayed_job) get delayed_jobs_path assert_response :success end end + + context "cancel action" do + should "work" do + put_auth cancel_delayed_job_path(@job), @user, xhr: true + assert_response :success + end + end + + context "retry action" do + should "work" do + put_auth retry_delayed_job_path(@job), @user, xhr: true + assert_response :success + end + end + + context "run action" do + should "work" do + put_auth run_delayed_job_path(@job), @user, xhr: true + assert_response :success + end + end + + context "destroy action" do + should "work" do + delete_auth delayed_job_path(@job), @user, xhr: true + assert_response :success + end + end end end diff --git a/test/functional/dtext_links_controller_test.rb b/test/functional/dtext_links_controller_test.rb new file mode 100644 index 000000000..17f6f274a --- /dev/null +++ b/test/functional/dtext_links_controller_test.rb @@ -0,0 +1,12 @@ +require "test_helper" + +class DtextLinksControllerTest < ActionDispatch::IntegrationTest + context "index action" do + should "work" do + @user = create(:user) + @wiki = as(@user) { create(:wiki_page, body: "[[test]]") } + get dtext_links_path + assert_response :success + end + end +end diff --git a/test/functional/explore/posts_controller_test.rb b/test/functional/explore/posts_controller_test.rb index 8d693eaab..b136904a1 100644 --- a/test/functional/explore/posts_controller_test.rb +++ b/test/functional/explore/posts_controller_test.rb @@ -4,10 +4,7 @@ module Explore class PostsControllerTest < ActionDispatch::IntegrationTest context "in all cases" do setup do - @user = create(:user) - as_user do - create(:post) - end + @post = create(:post) end context "#popular" do @@ -17,6 +14,15 @@ module Explore end end + context "#curated" do + should "render" do + @builder = create(:builder_user) + @post.add_favorite!(@builder) + get curated_explore_posts_path + assert_response :success + end + end + context "#searches" do should "render" do get searches_explore_posts_path diff --git a/test/functional/forum_topic_visits_controller_test.rb b/test/functional/forum_topic_visits_controller_test.rb new file mode 100644 index 000000000..7a8629520 --- /dev/null +++ b/test/functional/forum_topic_visits_controller_test.rb @@ -0,0 +1,13 @@ +require "test_helper" + +class ForumTopicVisitsControllerTest < ActionDispatch::IntegrationTest + context "index action" do + should "work for json responses" do + @user = create(:user) + @visit = as(@user) { create(:forum_topic_visit, user: @user) } + get_auth forum_topic_visits_path, @user, as: :json + + assert_response :success + end + end +end diff --git a/test/functional/ip_addresses_controller_test.rb b/test/functional/ip_addresses_controller_test.rb index c70d9509a..b4c212e50 100644 --- a/test/functional/ip_addresses_controller_test.rb +++ b/test/functional/ip_addresses_controller_test.rb @@ -40,5 +40,17 @@ class IpAddressesControllerTest < ActionDispatch::IntegrationTest assert_response 403 end end + + context "show action" do + should "be visible to mods" do + get_auth ip_address_path("1.1.1.1"), @mod + assert_response :success + end + + should "not be visible to members" do + get_auth ip_address_path("1.1.1.1"), @user + assert_response 403 + end + end end end diff --git a/test/functional/mod_actions_controller_test.rb b/test/functional/mod_actions_controller_test.rb index 28b156656..8d5466a45 100644 --- a/test/functional/mod_actions_controller_test.rb +++ b/test/functional/mod_actions_controller_test.rb @@ -2,11 +2,22 @@ require 'test_helper' class ModActionsControllerTest < ActionDispatch::IntegrationTest context "The mod actions controller" do + setup do + @mod_action = create(:mod_action) + end + context "index action" do should "work" do get mod_actions_path assert_response :success end end + + context "show action" do + should "work" do + get mod_action_path(@mod_action) + assert_redirected_to mod_actions_path(search: { id: @mod_action.id }) + end + end end end diff --git a/test/functional/modqueue_controller_text.rb b/test/functional/modqueue_controller_test.rb similarity index 100% rename from test/functional/modqueue_controller_text.rb rename to test/functional/modqueue_controller_test.rb diff --git a/test/functional/pixiv_ugoira_frame_data_controller_test.rb b/test/functional/pixiv_ugoira_frame_data_controller_test.rb new file mode 100644 index 000000000..7d398fbec --- /dev/null +++ b/test/functional/pixiv_ugoira_frame_data_controller_test.rb @@ -0,0 +1,11 @@ +require "test_helper" + +class PixivUgoiraFrameDataControllerTest < ActionDispatch::IntegrationTest + context "index action" do + should "work" do + create(:pixiv_ugoira_frame_data) + get pixiv_ugoira_frame_data_path, as: :json + assert_response :success + end + end +end diff --git a/test/functional/post_appeals_controller_test.rb b/test/functional/post_appeals_controller_test.rb index 2bf362a07..b3e0429a2 100644 --- a/test/functional/post_appeals_controller_test.rb +++ b/test/functional/post_appeals_controller_test.rb @@ -13,6 +13,14 @@ class PostAppealsControllerTest < ActionDispatch::IntegrationTest end end + context "show action" do + should "render" do + @appeal = create(:post_appeal) + get post_appeal_path(@appeal) + assert_redirected_to post_appeals_path(search: { id: @appeal.id }) + end + end + context "index action" do setup do as_user do diff --git a/test/functional/robots_controller_test.rb b/test/functional/robots_controller_test.rb new file mode 100644 index 000000000..c4e37173c --- /dev/null +++ b/test/functional/robots_controller_test.rb @@ -0,0 +1,10 @@ +require "test_helper" + +class RobotsControllerTest < ActionDispatch::IntegrationTest + context "index action" do + should "work" do + get robots_path(format: :text) + assert_response :success + end + end +end diff --git a/test/functional/static_controller_test.rb b/test/functional/static_controller_test.rb new file mode 100644 index 000000000..0fd2bd57b --- /dev/null +++ b/test/functional/static_controller_test.rb @@ -0,0 +1,65 @@ +require "test_helper" + +class StaticControllerTest < ActionDispatch::IntegrationTest + context "site_map action" do + should "work for anonymous users" do + get site_map_path + assert_response :success + end + + should "work for admin users" do + get_auth site_map_path, create(:admin_user) + assert_response :success + end + end + + context "sitemap action" do + should "work" do + create_list(:post, 3) + get sitemap_path, as: :xml + assert_response :success + end + end + + context "dtext_help action" do + should "work" do + get dtext_help_path(format: :js), xhr: true + assert_response :success + end + end + + context "terms_of_service action" do + should "work" do + get terms_of_service_path + assert_response :success + end + end + + context "not_found action" do + should "work" do + get "/qwoiqogieqg" + assert_response 404 + end + end + + context "bookmarklet action" do + should "work" do + get bookmarklet_path + assert_response :success + end + end + + context "contact action" do + should "work" do + get contact_path + assert_response :success + end + end + + context "keyboard_shortcuts action" do + should "work" do + get keyboard_shortcuts_path + assert_response :success + end + end +end diff --git a/test/functional/tag_aliases_controller_test.rb b/test/functional/tag_aliases_controller_test.rb index 1d7e52d08..f987f4580 100644 --- a/test/functional/tag_aliases_controller_test.rb +++ b/test/functional/tag_aliases_controller_test.rb @@ -18,6 +18,13 @@ class TagAliasesControllerTest < ActionDispatch::IntegrationTest end end + context "show action" do + should "work" do + get tag_alias_path(@tag_alias) + assert_response :success + end + end + context "destroy action" do should "allow admins to delete aliases" do delete_auth tag_alias_path(@tag_alias), create(:admin_user) diff --git a/test/functional/tag_implications_controller_test.rb b/test/functional/tag_implications_controller_test.rb index e3d66e8f8..c43858be3 100644 --- a/test/functional/tag_implications_controller_test.rb +++ b/test/functional/tag_implications_controller_test.rb @@ -18,6 +18,13 @@ class TagImplicationsControllerTest < ActionDispatch::IntegrationTest end end + context "show action" do + should "work" do + get tag_implication_path(@tag_implication) + assert_response :success + end + end + context "destroy action" do should "allow admins to delete implications" do delete_auth tag_implication_path(@tag_implication), create(:admin_user) diff --git a/test/functional/tags_controller_test.rb b/test/functional/tags_controller_test.rb index dac410f5c..957cf51a2 100644 --- a/test/functional/tags_controller_test.rb +++ b/test/functional/tags_controller_test.rb @@ -11,7 +11,7 @@ class TagsControllerTest < ActionDispatch::IntegrationTest context "edit action" do should "render" do - get_auth tag_path(@tag), @user, params: {:id => @tag.id} + get_auth edit_tag_path(@tag), @user assert_response :success end end diff --git a/test/functional/wiki_pages_controller_test.rb b/test/functional/wiki_pages_controller_test.rb index e23d89c0d..c98dd8458 100644 --- a/test/functional/wiki_pages_controller_test.rb +++ b/test/functional/wiki_pages_controller_test.rb @@ -140,11 +140,8 @@ class WikiPagesControllerTest < ActionDispatch::IntegrationTest context "edit action" do should "render" do - as_user do - @wiki_page = create(:wiki_page) - end - - get_auth wiki_page_path(@wiki_page), @mod + @wiki_page = as(@user) { create(:wiki_page) } + get_auth edit_wiki_page_path(@wiki_page), @user assert_response :success end end