From 6e0ef8abdbdbd411860d2b42898333823c0e065c Mon Sep 17 00:00:00 2001 From: lucasgomide Date: Mon, 3 Mar 2025 09:58:07 -0300 Subject: [PATCH 1/2] fix: ignore sqlite files Some .sqlite files were added after running rspec --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c111b3313..c8c53449b 100755 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.gem +*.sqlite* From 901a6da10df16eadbb4abb2a4cade1bcf5cbf1b1 Mon Sep 17 00:00:00 2001 From: lucasgomide Date: Mon, 3 Mar 2025 09:57:10 -0300 Subject: [PATCH 2/2] fix: Ensure compatibility with ActiveRecord <7 and 7+ for serialize ActiveRecord 7 introduced a change in the `serialize` method, requiring the `coder:` keyword argument instead of the previous syntax. This commit adds version detection to apply the correct `serialize` syntax dynamically. This ensures the library remains compatible across different versions of ActiveRecord without breaking older setups. --- .../lib/notification_handler/notification_lib.rb | 6 +++++- notification-settings/Gemfile.lock | 6 +++--- notification-settings/lib/notification_settings/settings.rb | 6 +++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/notification-handler/lib/notification_handler/notification_lib.rb b/notification-handler/lib/notification_handler/notification_lib.rb index 1aeafbdbd..9b4d4a097 100755 --- a/notification-handler/lib/notification_handler/notification_lib.rb +++ b/notification-handler/lib/notification_handler/notification_lib.rb @@ -11,7 +11,11 @@ module NotificationLib after_commit :cache - serialize :metadata, Hash + if ActiveRecord.gem_version >= Gem::Version.new('7.0.0') + serialize :metadata, type: Hash, coder: YAML + else + serialize :metadata, Hash + end belongs_to :target, polymorphic: true belongs_to :object, polymorphic: true, optional: true diff --git a/notification-settings/Gemfile.lock b/notification-settings/Gemfile.lock index 67bd11eb6..64c096dff 100644 --- a/notification-settings/Gemfile.lock +++ b/notification-settings/Gemfile.lock @@ -1,12 +1,12 @@ PATH remote: . specs: - notification-settings (3.0.3) + notification-settings (4.0.1) activemodel (>= 5.0) activerecord (>= 5.0) activesupport (>= 5.0) hashie (>= 3.6, < 6.0) - notification-handler (= 3.0.3) + notification-handler (= 4.0.1) railties (>= 5.0) GEM @@ -138,7 +138,7 @@ GEM nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) - notification-handler (3.0.3) + notification-handler (4.0.1) activerecord (>= 5.0) activesupport (>= 5.0) railties (>= 5.0) diff --git a/notification-settings/lib/notification_settings/settings.rb b/notification-settings/lib/notification_settings/settings.rb index f7e07043f..1e7ad65cb 100755 --- a/notification-settings/lib/notification_settings/settings.rb +++ b/notification-settings/lib/notification_settings/settings.rb @@ -10,7 +10,11 @@ module Settings included do before_validation :build_settings - serialize :settings, Hashie::Mash + if ActiveRecord.gem_version >= Gem::Version.new('7.0.0') + serialize :settings, type: Hashie::Mash, coder: YAML + else + serialize :settings, Hashie::Mash + end include NotificationSettings::Settings::InstanceMethods end