FIX: Do not allow null options for bookmark manager

FIX: Do not allow null options for bookmark manager

diff --git a/lib/bookmark_manager.rb b/lib/bookmark_manager.rb
index 9008818..44e6361 100644
--- a/lib/bookmark_manager.rb
+++ b/lib/bookmark_manager.rb
@@ -1,6 +1,8 @@
 # frozen_string_literal: true
 
 class BookmarkManager
+  DEFAULT_OPTIONS = { delete_when_reminder_sent: false }
+
   include HasErrors
 
   def initialize(user)
@@ -22,7 +24,7 @@ class BookmarkManager
         reminder_type: reminder_type,
         reminder_at: reminder_at,
         reminder_set_at: Time.zone.now
-      }.merge(options)
+      }.merge(default_options(options))
     )
 
     if bookmark.errors.any?
@@ -82,7 +84,7 @@ class BookmarkManager
         reminder_at: reminder_at,
         reminder_type: reminder_type,
         reminder_set_at: Time.zone.now
-      }.merge(options)
+      }.merge(default_options(options))
     )
 
     if bookmark.errors.any?
@@ -102,4 +104,8 @@ class BookmarkManager
     return if reminder_type.blank?
     reminder_type.is_a?(Integer) ? reminder_type : Bookmark.reminder_types[reminder_type.to_sym]
   end
+
+  def default_options(options)
+    DEFAULT_OPTIONS.merge(options) { |key, old, new| new.nil? ? old : new }
+  end
 end
diff --git a/spec/lib/bookmark_manager_spec.rb b/spec/lib/bookmark_manager_spec.rb
index 24bdd6b..6aabf79 100644
--- a/spec/lib/bookmark_manager_spec.rb
+++ b/spec/lib/bookmark_manager_spec.rb
@@ -53,6 +53,17 @@ RSpec.describe BookmarkManager do
       end
     end
 
+    context "when options are provided with null values" do
+      let(:options) { { delete_when_reminder_sent: nil } }
+
+      it "saves defaults successfully" do
+        subject.create(post_id: post.id, name: name, options: options)
+        bookmark = Bookmark.find_by(user: user)
+
+        expect(bookmark.delete_when_reminder_sent).to eq(false)
+      end
+    end
+
     context "when the bookmark already exists for the user & post" do
       before do
         Bookmark.create(post: post, user: user, topic: post.topic)

GitHub sha: 22dffe6f