-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(filters): fix search filter when used in collection (#1392)
Using the search filter in the filter collection resulted in an error where the filter did not have a model. This was caused because the class method `filterset.get_filters()` was used instead of the properly initialized `filterset.filters` where the model was properly set.
- Loading branch information
Jonas Metzener
authored
Feb 25, 2021
1 parent
3b600e2
commit d99db68
Showing
2 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
def test_search_in_filter_collection(db, schema_executor, form_factory): | ||
form_factory(name="Test 1") | ||
form_factory(name="Test 2") | ||
form_factory(name="Test 3") | ||
|
||
query = """ | ||
query($search: String!) { | ||
allForms(filter: [{ search: $search }]) { | ||
edges { | ||
node { | ||
slug | ||
name | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
|
||
result = schema_executor(query, variable_values={"search": "Test 2"}) | ||
assert not result.errors | ||
|
||
assert len(result.data["allForms"]["edges"]) == 1 | ||
assert result.data["allForms"]["edges"][0]["node"]["name"] == "Test 2" |