Files
fizzy/test/models/card/watchable_test.rb
T
Jorge Manrubia f1d76a7cb7 Exclude inactive users
The system user should never be a subsriber but we should not serve it if it is
2025-09-17 13:26:53 +02:00

48 lines
1.4 KiB
Ruby

require "test_helper"
class Card::WatchableTest < ActiveSupport::TestCase
setup do
Watch.destroy_all
Access.all.update!(involvement: :access_only)
end
test "watched_by?" do
assert_not cards(:logo).watched_by?(users(:kevin))
cards(:logo).watch_by users(:kevin)
assert cards(:logo).watched_by?(users(:kevin))
cards(:logo).unwatch_by users(:kevin)
assert_not cards(:logo).watched_by?(users(:kevin))
end
test "watched_by? when notifications are set on the collection" do
collections(:writebook).access_for(users(:kevin)).watching!
assert cards(:text).watched_by?(users(:kevin))
cards(:logo).unwatch_by users(:kevin)
assert_not cards(:logo).watched_by?(users(:kevin))
end
test "cards are initially watched by their creator" do
card = collections(:writebook).cards.create!(creator: users(:kevin))
assert card.watched_by?(users(:kevin))
end
test "watchers_and_subscribers" do
collections(:writebook).access_for(users(:kevin)).watching!
collections(:writebook).access_for(users(:jz)).watching!
cards(:logo).watch_by users(:kevin)
cards(:logo).unwatch_by users(:jz)
cards(:logo).watch_by users(:david)
assert_equal [ users(:kevin), users(:david) ].sort, cards(:logo).watchers_and_subscribers.sort
# Only active users
users(:david).system!
assert_equal [ users(:kevin) ].sort, cards(:logo).watchers_and_subscribers.sort
end
end