Add tests for all models with includes searches

This commit is contained in:
BrokenEagle
2020-07-19 04:06:51 +00:00
parent 34ca33e22f
commit a903bd95f9
34 changed files with 893 additions and 360 deletions

View File

@@ -8,10 +8,31 @@ class FavoriteGroupsControllerTest < ActionDispatch::IntegrationTest
end
context "index action" do
setup do
@mod_favgroup = create(:favorite_group, name: "monochrome", creator: build(:moderator_user, name: "fumimi"))
@private_favgroup = create(:favorite_group, creator: @user, is_public: false)
end
should "render" do
get favorite_groups_path
assert_response :success
end
should respond_to_search({}).with { [@mod_favgroup, @favgroup] }
should respond_to_search(name: "monochrome").with { @mod_favgroup }
context "using includes" do
should respond_to_search(creator_name: "fumimi").with { @mod_favgroup }
should respond_to_search(creator: {level: User::Levels::MEMBER}).with { @favgroup }
end
context "for private favorite groups as the creator" do
setup do
CurrentUser.user = @user
end
should respond_to_search(is_public: "false").with { @private_favgroup }
end
end
context "show action" do