Skip to content

Commit

Permalink
fix: escape stage name when running ensure_record_type task (#3827)
Browse files Browse the repository at this point in the history
Fixed a bug we recently ran into while attempting to run
`ensure_record_type` task against an org where there exists an
Opportunity StageName with a ampesand.

Co-authored-by: James Estevez <[email protected]>
  • Loading branch information
leo-dcfa and jstvz authored Sep 18, 2024
1 parent f1d93b1 commit 4aa7dd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cumulusci/tasks/salesforce/EnsureRecordTypes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import re
from xml.sax.saxutils import escape

from cumulusci.core.exceptions import TaskOptionsError
from cumulusci.core.utils import process_bool_arg
Expand Down Expand Up @@ -152,7 +153,7 @@ def _build_package(self):
record_type_developer_name=self.options[
"record_type_developer_name"
],
stage_name=self.options["stage_name"],
stage_name=escape(self.options["stage_name"]),
default=default,
)
business_process_link = BUSINESS_PROCESS_LINK.format(
Expand Down
11 changes: 5 additions & 6 deletions cumulusci/tasks/salesforce/tests/test_EnsureRecordTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<fullName>NPSP_Default</fullName>
<isActive>true</isActive>
<values>
<fullName>Test</fullName>
<fullName>Identify &amp; Qualify</fullName>
<default>false</default>
</values>
</businessProcesses>
Expand Down Expand Up @@ -79,7 +79,7 @@
"name": "StageName",
"picklistValues": [
{"value": "Bad", "active": False},
{"value": "Test", "active": True},
{"value": "Identify & Qualify", "active": True},
],
},
],
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_infers_correct_business_process(self):

assert task.options["generate_business_process"]
assert task.options["generate_record_type"]
assert task.options["stage_name"] == "Test"
assert task.options["stage_name"] == "Identify & Qualify"

def test_no_business_process_where_unneeded(self):
task = create_task(
Expand Down Expand Up @@ -178,7 +178,6 @@ def test_generates_record_type_and_business_process(self):
with open(os.path.join("objects", "Opportunity.object"), "r") as f:
opp_contents = f.read()
assert OPPORTUNITY_METADATA == opp_contents
assert OPPORTUNITY_METADATA == opp_contents
with open(os.path.join("package.xml"), "r") as f:
pkg_contents = f.read()
assert PACKAGE_XML == pkg_contents
Expand All @@ -203,8 +202,8 @@ def test_generates_record_type_and_business_process__case(self):
with temporary_dir():
task._build_package()
with open(os.path.join("objects", "Case.object"), "r") as f:
opp_contents = f.read()
assert CASE_METADATA == opp_contents
case_contents = f.read()
assert CASE_METADATA == case_contents
with open(os.path.join("package.xml"), "r") as f:
pkg_contents = f.read()
assert PACKAGE_XML == pkg_contents
Expand Down

0 comments on commit 4aa7dd0

Please sign in to comment.