feat: validate query conditions (#10595)

Query conditions can take in arbitrary values, this can cause SQL
errors. This PR fixes it
This commit is contained in:
Shivam Mishra
2024-12-17 17:16:37 +05:30
committed by GitHub
parent e3109dbb22
commit b34dac7bbe
14 changed files with 119 additions and 1 deletions

View File

@@ -46,6 +46,17 @@ RSpec.describe AutomationRules::ConditionValidationService do
end
end
context 'with wrong query operator' do
before do
rule.conditions = [{ 'values': ['open'], 'attribute_key': 'status', 'query_operator': 'invalid', 'filter_operator': 'attribute_changed' }]
rule.save
end
it 'returns false' do
expect(described_class.new(rule).perform).to be(false)
end
end
context 'with "attribute_changed" filter operator' do
before do
rule.conditions = [