diff --git a/gemfiles/rails_7.0.gemfile b/gemfiles/rails_7.0.gemfile index f32a1ff..f395ee7 100644 --- a/gemfiles/rails_7.0.gemfile +++ b/gemfiles/rails_7.0.gemfile @@ -3,6 +3,6 @@ source "https://rubygems.org" gem "rails", "~> 7.0.2" -gem "sqlite3" +gem "sqlite3", "~> 1.4.0" gemspec path: "../" diff --git a/lib/webhook_system/base_event.rb b/lib/webhook_system/base_event.rb index f8cce27..7f10526 100644 --- a/lib/webhook_system/base_event.rb +++ b/lib/webhook_system/base_event.rb @@ -6,8 +6,8 @@ module WebhookSystem class BaseEvent include PhModel - def initialize(*args, &block) - super(*args, &block) + def initialize(...) + super @event_id = SecureRandom.uuid.freeze end diff --git a/lib/webhook_system/encoder.rb b/lib/webhook_system/encoder.rb index 75837cd..cb1362a 100644 --- a/lib/webhook_system/encoder.rb +++ b/lib/webhook_system/encoder.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'base64' + module WebhookSystem # Class in charge of encoding and decoding encrypted payload diff --git a/lib/webhook_system/subscription.rb b/lib/webhook_system/subscription.rb index fba26bc..638cd70 100644 --- a/lib/webhook_system/subscription.rb +++ b/lib/webhook_system/subscription.rb @@ -53,10 +53,8 @@ def topic_names=(new_topics) new_topics.reject!(&:blank?) add_topics = new_topics - topic_names - new_topics_attributes = [] - - topics.each do |topic| - new_topics_attributes << { + new_topics_attributes = topics.map do |topic| + { id: topic.id, name: topic.name, _destroy: new_topics.exclude?(topic.name), diff --git a/test.db-shm b/test.db-shm new file mode 100644 index 0000000..b371393 Binary files /dev/null and b/test.db-shm differ diff --git a/test.db-wal b/test.db-wal new file mode 100644 index 0000000..0e80a56 Binary files /dev/null and b/test.db-wal differ