action_tracker_notification_test.rb
1.43 KB
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
48
49
50
51
require File.dirname(__FILE__) + '/../test_helper'
class ActionTrackerNotificationTest < ActiveSupport::TestCase
should "have the profile" do
a = ActionTrackerNotification.new
a.valid?
assert a.errors.invalid?(:profile_id)
a.profile_id= 1
a.valid?
assert !a.errors.invalid?(:profile_id)
end
should "have the action tracker" do
a = ActionTrackerNotification.new
a.valid?
assert a.errors.invalid?(:action_tracker_id)
a.action_tracker_id= 1
a.valid?
assert !a.errors.invalid?(:action_tracker_id)
end
should "be associated to Person" do
person = fast_create(Person)
a = ActionTrackerNotification.new
assert_nothing_raised do
a.profile = person
end
end
should "be associated to ActionTracker" do
action_tracker = ActionTracker::Record.new
a = ActionTrackerNotification.new
assert_nothing_raised do
a.action_tracker= action_tracker
end
end
should "destroy the notifications if the activity is destroyed" do
action_tracker = fast_create(ActionTracker::Record)
count = ActionTrackerNotification.count
fast_create(ActionTrackerNotification, :action_tracker_id => action_tracker.id)
fast_create(ActionTrackerNotification, :action_tracker_id => action_tracker.id)
fast_create(ActionTrackerNotification, :action_tracker_id => action_tracker.id)
action_tracker.destroy
assert_equal count, ActionTrackerNotification.count
end
end