Skip to content

Commit 83584cc

Browse files
committed
Handle string field names in CustomFieldList#respond_to?
Previously `respond_to?` assumed it was given a symbol argument, so it directly checked for that argument in the fields, which are force-keyed as symbols. If you passed it a string argument, it wouldn't find the corresponding field, impying it didn't respond to such a method. Now, the argument is explicitly cast to a symbol before checking if such a field exists, supporting checking `respond_to?` with both argument types.
1 parent dd693a3 commit 83584cc

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
### Fixed
88
* Revert recent proxy changes which breaks proxy usage by @andrewdicken-stripe in https://github.com/NetSweet/netsuite/pull/579
9+
* Handle string field names in `CustomFieldList#respond_to?` (#606)
910

1011
### Breaking Changes
1112

lib/netsuite/records/custom_field_list.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def method_missing(sym, *args, &block)
6060
super(sym, *args, &block)
6161
end
6262

63-
def respond_to?(sym, include_private = false)
64-
return true if @custom_fields_assoc.include?(sym)
63+
def respond_to?(method, include_private = false)
64+
return true if @custom_fields_assoc.include?(method.to_sym)
6565
super
6666
end
6767

spec/netsuite/records/custom_field_list_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,14 @@
273273

274274
# field accessors are tested elsewhere, but let's run tests here to check various field types
275275
expect(list).to respond_to(:custbody_multipleselectfield)
276+
expect(list).to respond_to('custbody_multipleselectfield')
276277
expect(list).to respond_to(:custbody_salesclassification)
278+
expect(list).to respond_to('custbody_salesclassification')
277279
expect(list).to respond_to(:custentity_registeredonline)
280+
expect(list).to respond_to('custentity_registeredonline')
281+
282+
expect(list).to_not respond_to(:non_existant_field)
283+
expect(list).to_not respond_to('non_existant_field')
278284

279285
expect(list.to_record).to eql(record)
280286
expect(list.to_record.length).to eq(1)

0 commit comments

Comments
 (0)