Reevaluate automatic coverage on time tag events
This commit is contained in:
parent
b499b2dfea
commit
8a142dccf2
@ -153,7 +153,9 @@ def evaluate(workflows, context, trigger):
|
||||
break
|
||||
if context.get('pending_billing_tag_suggestions') or any(action['type']=='suggest_tag' for action in actions):
|
||||
return {'status': 'manual_review', 'method': None, 'reason': 'pending_tag_approval', 'actions': actions, 'trace': trace}
|
||||
if selected is None and not stopped and not context.get('target_workflow_id') and trigger in ('time.created', 'time.updated'):
|
||||
time_coverage_trigger = trigger in ('time.created', 'time.updated') or (
|
||||
context.get('entity_type') in ('time', 'time_entry') and trigger in ('tags.added', 'tags.removed', 'tags.changed'))
|
||||
if selected is None and not stopped and not context.get('target_workflow_id') and time_coverage_trigger:
|
||||
automatic = automatic_coverage_choices(context)
|
||||
trace.append({'source': 'resource_coverage', 'matched': bool(automatic), 'choices': automatic})
|
||||
if len(automatic) > 1:
|
||||
|
||||
@ -125,3 +125,10 @@ def test_automatic_evaluation_does_not_mutate_resources_or_context():
|
||||
before = deepcopy(supplied)
|
||||
evaluate([], supplied, 'time.created')
|
||||
assert supplied == before
|
||||
|
||||
@pytest.mark.parametrize('trigger', ['tags.added', 'tags.removed', 'tags.changed'])
|
||||
def test_time_tag_events_retain_automatic_coverage(trigger):
|
||||
context = {'entity_type': 'time_entry', 'tag_ids': [7], 'agreements': [{'id': 2, 'workflow_coverage': {'tag_ids': [7]}}]}
|
||||
assert evaluate([], context, trigger)['method'] == 'subscription'
|
||||
context['tag_ids'] = []
|
||||
assert evaluate([], context, trigger)['status'] == 'manual_review'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user