Files
fizzy/test/models/bubble/watchable_test.rb
T
Kevin McConnell eaf4903afc Formatting
2025-02-28 11:48:29 +00:00

47 lines
1.3 KiB
Ruby

require "test_helper"
class Bubble::WatchableTest < ActiveSupport::TestCase
setup do
Watch.destroy_all
Subscription.destroy_all
end
test "watched_by?" do
assert_not bubbles(:logo).watched_by?(users(:kevin))
bubbles(:logo).set_watching(users(:kevin), true)
assert bubbles(:logo).watched_by?(users(:kevin))
bubbles(:logo).set_watching(users(:kevin), false)
assert_not bubbles(:logo).watched_by?(users(:kevin))
end
test "watched_by? when subscribed to the bucket" do
buckets(:writebook).subscribe(users(:kevin))
assert bubbles(:text).watched_by?(users(:kevin))
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
test "watchers_and_subscribers" do
buckets(:writebook).subscribe(users(:kevin))
buckets(:writebook).subscribe(users(:jz))
bubbles(:logo).set_watching(users(:kevin), true)
bubbles(:logo).set_watching(users(:jz), false)
bubbles(:logo).set_watching(users(:david), true)
assert_equal [ users(:kevin), users(:david) ].sort, bubbles(:logo).watchers_and_subscribers.sort
end
end