From b47406c3f9517440c3863bed5eaf7240a76dfda8 Mon Sep 17 00:00:00 2001 From: Bert McCutchen Date: Thu, 17 Jul 2025 14:27:15 -0400 Subject: [PATCH 1/4] Reverted accidental change to object creation during sync --- README.md | 2 ++ lib/salesforce_ar_sync/salesforce_sync.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c096dad..fa197d8 100644 --- a/README.md +++ b/README.md @@ -327,6 +327,8 @@ configuration variable _SALESFORCE_AR_SYNC_CONFIG["SYNC_ENABLED"]_ You can trigger a manual sync of any configured attributes. All checks to skip syncing or to sync asynchronously will still be executed. +If the record does not exist in Salesforce, the provided attributes will be ignored and all attributes will be synced. + ```ruby my_user_record.salesforce_sync(:email) diff --git a/lib/salesforce_ar_sync/salesforce_sync.rb b/lib/salesforce_ar_sync/salesforce_sync.rb index d145fc8..cc0feed 100644 --- a/lib/salesforce_ar_sync/salesforce_sync.rb +++ b/lib/salesforce_ar_sync/salesforce_sync.rb @@ -224,8 +224,8 @@ def salesforce_sync(*attrs) else if salesforce_object_exists? salesforce_update_object(attributes_to_update) if attributes_to_update.present? - else - salesforce_create_object(attributes_to_update(!new_record?)) if salesforce_id.nil? + elsif salesforce_id.nil? + salesforce_create_object(salesforce_attributes_to_update(!new_record?)) end end rescue Exception => ex From b31b7f4ebb0340baaa18fe85c95cf917f4f04705 Mon Sep 17 00:00:00 2001 From: Bert McCutchen Date: Thu, 17 Jul 2025 14:30:18 -0400 Subject: [PATCH 2/4] Bumped version to 5.2.1 --- CHANGELOG.md | 3 +++ lib/salesforce_ar_sync/version.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e2f775..ebbce09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,3 +45,6 @@ # Version 5.2.0 * Added the ability to manually trigger syncing of specific model attributes. + +# Version 5.2.1 +* Reverted accidental change to object creation during sync. diff --git a/lib/salesforce_ar_sync/version.rb b/lib/salesforce_ar_sync/version.rb index 0120744..6586453 100644 --- a/lib/salesforce_ar_sync/version.rb +++ b/lib/salesforce_ar_sync/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module SalesforceArSync - VERSION = '5.2.0' + VERSION = '5.2.1' end From 77ac8c03859712b202db219e3faf00a454b94c23 Mon Sep 17 00:00:00 2001 From: Bert McCutchen Date: Thu, 17 Jul 2025 14:33:59 -0400 Subject: [PATCH 3/4] Added CI for the test suite --- .github/workflows/gem-tests.yml | 32 ++++++++++++++++++++++++++++++++ CHANGELOG.md | 1 + 2 files changed, 33 insertions(+) create mode 100644 .github/workflows/gem-tests.yml diff --git a/.github/workflows/gem-tests.yml b/.github/workflows/gem-tests.yml new file mode 100644 index 0000000..bb9c775 --- /dev/null +++ b/.github/workflows/gem-tests.yml @@ -0,0 +1,32 @@ +# Only test Ruby maintenance branches. +# https://www.ruby-lang.org/en/downloads/branches +name: Gem Tests +on: + push: + branches: + - master + pull_request: + branches: + - master +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + tests_matrix: + runs-on: ubuntu-latest + timeout-minutes: 3 + strategy: + matrix: + ruby: + - "3.2" + - "3.3" + - "3.4" + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Run Test Suite + run: ./test diff --git a/CHANGELOG.md b/CHANGELOG.md index ebbce09..afcee48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,3 +48,4 @@ # Version 5.2.1 * Reverted accidental change to object creation during sync. +* Added CI for the test suite. From ad334bbc96bb75939ee1217af6887a74e7f5c0cb Mon Sep 17 00:00:00 2001 From: Bert McCutchen Date: Thu, 17 Jul 2025 14:39:04 -0400 Subject: [PATCH 4/4] Added ostruct to gemfile and required into test suite --- Gemfile | 1 + gemfiles/rails_7.1.gemfile | 1 + gemfiles/rails_7.2.gemfile | 1 + gemfiles/rails_8.0.gemfile | 1 + spec/salesforce_ar_sync/salesforce_ar_sync_spec.rb | 2 +- spec/spec_helper.rb | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 2b83d8a..b7744a4 100644 --- a/Gemfile +++ b/Gemfile @@ -4,3 +4,4 @@ gemspec gem 'appraisal' gem 'debug' +gem 'ostruct' diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index 498c8fb..c0ef45a 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -4,6 +4,7 @@ source "https://rubygems.org" gem "appraisal" gem "debug" +gem "ostruct" gem "rails", "~> 7.1.0" gemspec path: "../" diff --git a/gemfiles/rails_7.2.gemfile b/gemfiles/rails_7.2.gemfile index 72e5efe..f1c5a86 100644 --- a/gemfiles/rails_7.2.gemfile +++ b/gemfiles/rails_7.2.gemfile @@ -4,6 +4,7 @@ source "https://rubygems.org" gem "appraisal" gem "debug" +gem "ostruct" gem "rails", "~> 7.2.0" gemspec path: "../" diff --git a/gemfiles/rails_8.0.gemfile b/gemfiles/rails_8.0.gemfile index 4c2c19a..2f6fd04 100644 --- a/gemfiles/rails_8.0.gemfile +++ b/gemfiles/rails_8.0.gemfile @@ -4,6 +4,7 @@ source "https://rubygems.org" gem "appraisal" gem "debug" +gem "ostruct" gem "rails", "~> 8.0.0" gemspec path: "../" diff --git a/spec/salesforce_ar_sync/salesforce_ar_sync_spec.rb b/spec/salesforce_ar_sync/salesforce_ar_sync_spec.rb index 71b1ece..49d8e78 100644 --- a/spec/salesforce_ar_sync/salesforce_ar_sync_spec.rb +++ b/spec/salesforce_ar_sync/salesforce_ar_sync_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper.rb' +require 'spec_helper' # for testing our environment variables SalesforceArSync.config = {} diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ae736e6..4359704 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ require 'bundler/setup' require 'debug' +require 'ostruct' require 'rails/all' require 'salesforce_ar_sync' require 'active_record'