Creators watch their own bubble by default

This commit is contained in:
Kevin McConnell
2025-02-26 10:42:18 +00:00
parent 4009553ffc
commit 84d06c7f0b
2 changed files with 15 additions and 0 deletions
+7
View File
@@ -3,6 +3,8 @@ module Bubble::Watchable
included do
has_many :watches, dependent: :destroy
after_create :set_watching_for_creator
end
def watched_by?(user)
@@ -17,4 +19,9 @@ module Bubble::Watchable
User.where(id: bucket.subscribers.pluck(:id) +
watches.watching.pluck(:user_id) - watches.not_watching.pluck(:user_id))
end
private
def set_watching_for_creator
set_watching(creator, true)
end
end
+8
View File
@@ -24,4 +24,12 @@ class Bubble::WatchableTest < ActiveSupport::TestCase
bubbles(:logo).set_watching(users(:kevin), false)
assert_not bubbles(:logo).watched_by?(users(:kevin))
end
test "bubbles are initially watched by their creator" do
buckets(:writebook).unsubscribe(users(:kevin))
bubble = buckets(:writebook).bubbles.create!(creator: users(:kevin))
assert bubble.watched_by?(users(:kevin))
end
end