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

@@ -3,7 +3,7 @@ require 'test_helper'
class PostApprovalsControllerTest < ActionDispatch::IntegrationTest
context "The post approvals controller" do
setup do
@approver = create(:approver)
@approver = create(:approver, name: "eiki")
end
context "create action" do
@@ -37,11 +37,25 @@ class PostApprovalsControllerTest < ActionDispatch::IntegrationTest
end
context "index action" do
setup do
@post = create(:post, tag_string: "touhou", is_pending: true, uploader: build(:user, name: "komachi", created_at: 2.weeks.ago))
@post_approval = create(:post_approval, post: @post)
@user_approval = create(:post_approval, user: @approver)
@unrelated_approval = create(:post_approval)
end
should "render" do
@approval = create(:post_approval)
get post_approvals_path
assert_response :success
end
should respond_to_search({}).with { [@unrelated_approval, @user_approval, @post_approval] }
context "using includes" do
should respond_to_search(user_name: "eiki").with { @user_approval }
should respond_to_search(post_tags_match: "touhou").with { @post_approval }
should respond_to_search(post: {uploader_name: "komachi"}).with { @post_approval }
end
end
end
end