tests: fix test failures in #4553.

This commit is contained in:
evazion
2020-08-17 15:19:34 -05:00
parent e5f459bd52
commit e196514de8
3 changed files with 19 additions and 20 deletions

View File

@@ -2,31 +2,33 @@ require 'test_helper'
class ModActionsControllerTest < ActionDispatch::IntegrationTest
context "The mod actions controller" do
setup do
@mod_action = create(:mod_action, description: "blah", category: "post_delete")
end
context "index action" do
setup do
@ban = create(:mod_action, category: :post_ban)
@unban = create(:mod_action, category: :post_unban)
end
should "work" do
create(:mod_action)
get mod_actions_path
assert_response :success
end
should respond_to_search({}).with { [@unrelated_action, @promote_action, @mod_action] }
should respond_to_search(category: ModAction.categories["user_level_change"]).with { @promote_action }
should respond_to_search(description_matches: "blah").with { @mod_action }
context "searching" do
setup do
@mod_action = create(:mod_action, description: "blah")
@promote_action = create(:mod_action, category: "user_level_change", creator: create(:builder_user, name: "rumia"))
end
should respond_to_search({}).with { [@promote_action, @mod_action] }
should respond_to_search(category: ModAction.categories["user_level_change"].to_s).with { @promote_action }
should respond_to_search(description_matches: "blah").with { @mod_action }
context "using includes" do
should respond_to_search(creator_name: "rumia").with { @promote_action }
should respond_to_search(creator: {level: User::Levels::BUILDER}).with { @promote_action }
should respond_to_search(creator: { level: User::Levels::BUILDER }).with { @promote_action }
end
context "category enum searches" do
setup do
@ban = create(:mod_action, category: :post_ban)
@unban = create(:mod_action, category: :post_unban)
end
should respond_to_search(category: "post_ban").with { [@ban] }
should respond_to_search(category: "post_unban").with { [@unban] }
should respond_to_search(category: "Post_ban").with { [@ban] }
@@ -36,7 +38,6 @@ class ModActionsControllerTest < ActionDispatch::IntegrationTest
should respond_to_search(category_id: "44").with { [@ban] }
should respond_to_search(category_id: "44,45").with { [@unban, @ban] }
should respond_to_search(category_id: ">=44").with { [@unban, @ban] }
end
end