Creators watch their own bubble by default
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user