Skip to content

Commit 4aa7dd0

Browse files
leo-dcfajstvz
andauthored
fix: escape stage name when running ensure_record_type task (#3827)
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 <jestevez@salesforce.com>
1 parent f1d93b1 commit 4aa7dd0

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

cumulusci/tasks/salesforce/EnsureRecordTypes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import re
3+
from xml.sax.saxutils import escape
34

45
from cumulusci.core.exceptions import TaskOptionsError
56
from cumulusci.core.utils import process_bool_arg
@@ -152,7 +153,7 @@ def _build_package(self):
152153
record_type_developer_name=self.options[
153154
"record_type_developer_name"
154155
],
155-
stage_name=self.options["stage_name"],
156+
stage_name=escape(self.options["stage_name"]),
156157
default=default,
157158
)
158159
business_process_link = BUSINESS_PROCESS_LINK.format(

cumulusci/tasks/salesforce/tests/test_EnsureRecordTypes.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<fullName>NPSP_Default</fullName>
1616
<isActive>true</isActive>
1717
<values>
18-
<fullName>Test</fullName>
18+
<fullName>Identify &amp; Qualify</fullName>
1919
<default>false</default>
2020
</values>
2121
</businessProcesses>
@@ -79,7 +79,7 @@
7979
"name": "StageName",
8080
"picklistValues": [
8181
{"value": "Bad", "active": False},
82-
{"value": "Test", "active": True},
82+
{"value": "Identify & Qualify", "active": True},
8383
],
8484
},
8585
],
@@ -134,7 +134,7 @@ def test_infers_correct_business_process(self):
134134

135135
assert task.options["generate_business_process"]
136136
assert task.options["generate_record_type"]
137-
assert task.options["stage_name"] == "Test"
137+
assert task.options["stage_name"] == "Identify & Qualify"
138138

139139
def test_no_business_process_where_unneeded(self):
140140
task = create_task(
@@ -178,7 +178,6 @@ def test_generates_record_type_and_business_process(self):
178178
with open(os.path.join("objects", "Opportunity.object"), "r") as f:
179179
opp_contents = f.read()
180180
assert OPPORTUNITY_METADATA == opp_contents
181-
assert OPPORTUNITY_METADATA == opp_contents
182181
with open(os.path.join("package.xml"), "r") as f:
183182
pkg_contents = f.read()
184183
assert PACKAGE_XML == pkg_contents
@@ -203,8 +202,8 @@ def test_generates_record_type_and_business_process__case(self):
203202
with temporary_dir():
204203
task._build_package()
205204
with open(os.path.join("objects", "Case.object"), "r") as f:
206-
opp_contents = f.read()
207-
assert CASE_METADATA == opp_contents
205+
case_contents = f.read()
206+
assert CASE_METADATA == case_contents
208207
with open(os.path.join("package.xml"), "r") as f:
209208
pkg_contents = f.read()
210209
assert PACKAGE_XML == pkg_contents

0 commit comments

Comments
 (0)