From a16abcfc44b4bb7a0dec4b849e53c522798aa5a7 Mon Sep 17 00:00:00 2001 From: David Flaherty Date: Fri, 17 Jun 2022 12:11:30 -0400 Subject: [PATCH] Status detail of after_submit_failed is not error (#550) Addresses issue #444, where some successful requests return an empty error object. See https://system.netsuite.com/help/helpcenter/en_US/WSDiff/2018_2/FolderComparisonReport_files/FileComparisonReport24.html, line 914 for the change to the platformCore schema, https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4407992281.html for a description of afterSubmit scripts, and https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_N3536574.html#bridgehead_1515748728 for a discussion of error reporting for these scripts. Also added a line for File requests in the add action spec b/c the existing fixture already includes the `after_submit_failed` field. Co-authored-by: Lily Burtness Co-authored-by: Shana Schundler Co-authored-by: Lily Burtness Co-authored-by: Shana Schundler --- lib/netsuite/actions/add.rb | 3 ++- spec/netsuite/actions/add_spec.rb | 6 ++++-- spec/support/fixtures/add/add_invoice.xml | 14 +++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/netsuite/actions/add.rb b/lib/netsuite/actions/add.rb index 8acc99e86..e6ef05aa5 100644 --- a/lib/netsuite/actions/add.rb +++ b/lib/netsuite/actions/add.rb @@ -70,8 +70,9 @@ def errors error_obj = response_hash[:status][:status_detail] error_obj = [error_obj] if error_obj.class == Hash error_obj.map do |error| + next if error.keys == [:after_submit_failed] NetSuite::Error.new(error) - end + end.compact end module Support diff --git a/spec/netsuite/actions/add_spec.rb b/spec/netsuite/actions/add_spec.rb index 2be80d272..aba9031e5 100644 --- a/spec/netsuite/actions/add_spec.rb +++ b/spec/netsuite/actions/add_spec.rb @@ -53,10 +53,11 @@ NetSuite::Actions::Add.call([invoice]) end - it 'returns a valid Response object' do + it 'returns a valid Response object with no errors' do response = NetSuite::Actions::Add.call([invoice]) expect(response).to be_kind_of(NetSuite::Response) expect(response).to be_success + expect(response.errors).to be_empty end end @@ -136,10 +137,11 @@ NetSuite::Actions::Add.call([file]) end - it 'returns a valid Response object' do + it 'returns a valid Response object with no errors' do response = NetSuite::Actions::Add.call([file]) expect(response).to be_kind_of(NetSuite::Response) expect(response).to be_success + expect(response.errors).to be_empty end it 'properly extracts internal ID from response' do diff --git a/spec/support/fixtures/add/add_invoice.xml b/spec/support/fixtures/add/add_invoice.xml index 06e74c1fc..9befd0dac 100644 --- a/spec/support/fixtures/add/add_invoice.xml +++ b/spec/support/fixtures/add/add_invoice.xml @@ -1,15 +1,19 @@ - + WEBSERVICES_3392464_1220201115821392011296470399_67055c545d0 - - - - + + + + + false + + +