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,24 +8,25 @@ class NotesControllerTest < ActionDispatch::IntegrationTest
end
context "index action" do
should "list all notes" do
setup do
as(@user) do
@post_note = create(:note, post: build(:post, id: 2001, tag_string: "touhou"))
@deleted_note = create(:note, is_active: false)
end
end
should "render" do
get notes_path
assert_response :success
end
should "list all notes (with search)" do
params = {
group_by: "note",
search: {
body_matches: "000",
is_active: true,
post_id: @note.post_id,
post_tags_match: @note.post.tag_array.first
}
}
should respond_to_search({}).with { [@deleted_note, @post_note, @note] }
should respond_to_search(body_matches: "000").with { @note }
should respond_to_search(is_active: "true").with { [@post_note, @note] }
get notes_path, params: params
assert_response :success
context "using includes" do
should respond_to_search(post_id: 2001).with { @post_note }
should respond_to_search(post_tags_match: "touhou").with { @post_note }
end
end