From davidj503 at gmail.com Wed Sep 5 11:21:24 2007 From: davidj503 at gmail.com (David James) Date: Wed, 5 Sep 2007 11:21:24 -0400 Subject: [Activesfdc-news] valid? gives incorrect result Message-ID: <59b5d4330709050821s2e7811f0n3e19c19fcf7e1c53@mail.gmail.com> Dear ActiveSalesforce Community, I wanted to call attention to a bug: http://rubyforge.org/tracker/index.php?func=detail&aid=13501&group_id=1201&atid=4729 In short, not being able to trust valid? makes unit testing ASF problematic. -David Detailed description class SfContact < ActiveRecord::Base establish_connection :salesforce include ActiveSalesforce::ActiveRecord::Mixin set_table_name "contact" end # script/console contact1 = SfContact.new contact1.save # actual result: ActiveSalesforce::ASFError: statusCodeREQUIRED_FIELD_MISSINGfieldsLastNamemessageRequired fields are missing: [LastName] # expected result: same (better use of whitespace would be nice, though) contact2 = SfContact.new contact2.valid? # actual result: true # expected result: false From davidj503 at gmail.com Wed Sep 5 11:25:42 2007 From: davidj503 at gmail.com (David James) Date: Wed, 5 Sep 2007 11:25:42 -0400 Subject: [Activesfdc-news] 2nd use of save gives ActiveRecord::StatementInvalid instead of ActiveSalesforce::ASFError Message-ID: <59b5d4330709050825tb1b85f2w5ed95d2a5cf1cd3d@mail.gmail.com> Just wanted to call attention to another bug I've found in ASF: Somewhat along the lines of my previous email, I'm digging into ASF and finding that it behaves differently in some ways than ActiveRecord. -David 2nd use of save gives ActiveRecord::StatementInvalid instead of ActiveSalesforce::ASFError Detailed description class SfContact < ActiveRecord::Base establish_connection :salesforce include ActiveSalesforce::ActiveRecord::Mixin set_table_name "contact" end # script/console jim = SfContact.new jim.save # actual result: ActiveSalesforce::ASFError: statusCodeREQUIRED_FIELD_MISSINGfieldsLastNamemessageRequired fields are missing: [LastName] # expected result: same (better use of whitespace would be nice, though) jim.save # expected result: ActiveSalesforce::ASFError with explanation of validation failure # actual result: ActiveRecord::StatementInvalid: NoMethodError: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[]: UPDATE contact SET other_postal_code = NULL, name = NULL, mailing_state = NULL, last_cu_update_date = NULL, department = NULL, master_record_id = NULL, mailing_street = NULL, title = NULL, salutation = NULL, other_state = NULL, mailing_postal_code = NULL, birthdate = NULL, account_id = NULL, last_activity_date = NULL, last_modified_by_id = NULL, created_date = NULL, created_by_id = NULL, assistant_name = NULL, system_modstamp = NULL, mailing_country = NULL, last_cu_request_date = NULL, description = NULL, assistant_phone = NULL, phone = NULL, owner_id = NULL, other_street = NULL, other_country = NULL, home_phone = NULL, fax = NULL, other_city = NULL, lead_source = NULL, languages__c = NULL, is_deleted = NULL, first_name = NULL, reports_to_id = NULL, other_phone = NULL, mailing_city = NULL, level__c = NULL, last_name = NULL, last_modified_date = NULL, mobile_phone = NULL, email = NULL WHERE id = ''