-
-
Notifications
You must be signed in to change notification settings - Fork 178
/
has_notifications_test.rb
47 lines (37 loc) · 1.24 KB
/
has_notifications_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require "test_helper"
class HasNotificationsTest < ActiveSupport::TestCase
test "has_noticed_notifications" do
assert User.respond_to?(:has_noticed_notifications)
end
test "noticed notifications association" do
assert user.respond_to?(:notifications_as_user)
end
test "noticed notifications with custom name" do
assert user.respond_to?(:notifications_as_owner)
end
test "association returns notifications" do
assert_difference "user.notifications_as_user.count" do
SimpleNotifier.with(user: user, message: "test").deliver(user)
end
end
test "association with custom name returns notifications" do
assert_difference "user.notifications_as_owner.count" do
SimpleNotifier.with(owner: user, message: "test").deliver(user)
end
end
test "deletes notifications with matching param" do
SimpleNotifier.with(user: user, message: "test").deliver(users(:two))
assert_difference "Noticed::Event.count", -1 do
user.destroy
end
end
test "doesn't delete notifications when disabled" do
SimpleNotifier.with(owner: user, message: "test").deliver(users(:two))
assert_no_difference "Noticed::Event.count" do
user.destroy
end
end
def user
@user ||= users(:one)
end
end