Skip to content

Commit 931d57e

Browse files
authored
Fixes #1096 - Ignores '---' values for mapped fields on create (#1097)
* Fixes #1096 - Ignores '---' values for mapped fields on create * Adding unit test to ensure we skip setting points to 0 for a create step. * Making test name better
1 parent 8d1eae2 commit 931d57e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

jbi/steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _maybe_update_issue_mapped_field(
220220
target_value = getattr(parameters, f"{source_field}_map").get(source_value)
221221

222222
# If field is empty on create, or update is about another field, then nothing to do.
223-
if (context.operation == Operation.CREATE and source_value == "") or (
223+
if (context.operation == Operation.CREATE and source_value in ["", "---"]) or (
224224
context.operation == Operation.UPDATE
225225
and source_field not in context.event.changed_fields()
226226
):

tests/unit/test_steps.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,30 @@ def test_update_issue_points_removed(
10151015
)
10161016

10171017

1018+
def test_empty_issue_points_ignored_on_create(
1019+
action_context_factory,
1020+
mocked_jira,
1021+
action_params_factory,
1022+
webhook_event_change_factory,
1023+
):
1024+
action_context = action_context_factory(
1025+
operation=Operation.CREATE,
1026+
current_step="maybe_update_issue_points",
1027+
bug__see_also=["https://mozilla.atlassian.net/browse/JBI-234"],
1028+
jira__issue="JBI-234",
1029+
bug__cf_fx_points="---",
1030+
)
1031+
1032+
params = action_params_factory(
1033+
jira_project_key=action_context.jira.project,
1034+
)
1035+
steps.maybe_update_issue_points(
1036+
action_context, parameters=params, jira_service=JiraService(mocked_jira)
1037+
)
1038+
1039+
mocked_jira.update_issue_field.assert_not_called()
1040+
1041+
10181042
def test_update_issue_points_missing_in_map(
10191043
action_context_factory,
10201044
mocked_jira,

0 commit comments

Comments
 (0)