Call subscribe_to_mailchimp_newsletter after the transaction is commited (#13969)

* Call subscribe_to_mailchimp_newsletter by after_commit instead of after_save

* s/save/commit
This commit is contained in:
Takuma 2021-06-14 23:05:46 +09:00 committed by GitHub
parent e37346845d
commit 7e969fa682
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -346,10 +346,10 @@ class User < ApplicationRecord
# NOTE: @citizen428 Temporary while migrating to generalized profiles
after_save { |user| user.profile&.save if user.profile&.changed? }
after_save :subscribe_to_mailchimp_newsletter
after_create_commit :send_welcome_notification
after_commit :subscribe_to_mailchimp_newsletter
after_commit :sync_users_settings_table, :sync_users_notification_settings_table, on: %i[create update]
after_commit :bust_cache

View file

@ -435,7 +435,7 @@ RSpec.describe User, type: :model do
end
end
context "when callbacks are triggered after save" do
context "when callbacks are triggered after commit" do
describe "subscribing to mailchimp newsletter" do
let(:user) { build(:user) }