From 3b7f876fc0c17d42543224c72436254db5381018 Mon Sep 17 00:00:00 2001 From: yuenmichelle1 Date: Wed, 23 Oct 2024 10:57:37 -0500 Subject: [PATCH] Rails 5.2 specs - Remove calling run_callbacks commit spec workarounds (#378) * ensure creation when testing after_commit callbacks * remove run_callbacks workaround on specs, after_commit specs should work without calling callback in Rails 5+ * remove accidental secondary creation --- spec/models/announcement_spec.rb | 4 ++-- spec/models/notification_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/models/announcement_spec.rb b/spec/models/announcement_spec.rb index 6f5c7d62..681aac48 100644 --- a/spec/models/announcement_spec.rb +++ b/spec/models/announcement_spec.rb @@ -9,10 +9,10 @@ end context 'creating' do - let(:announcement){ create :announcement } + let(:announcement){ build :announcement } it 'should publish' do expect(AnnouncementWorker).to receive :perform_async - announcement.run_callbacks :commit + announcement.save! end end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 01edc2b8..8d1419aa 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -30,10 +30,10 @@ end context 'creating' do - let(:notification){ create :notification } + let(:notification){ build :notification } it 'should publish' do expect(NotificationWorker).to receive :perform_async - notification.run_callbacks :commit + notification.save! end end