Commit 791c1406333cb61e6ab1965b9fecf64f0bd66d86

Authored by Rodrigo Souto
1 parent 9c9e90ee

person-notifier: fix tests

Showing 1 changed file with 8 additions and 9 deletions   Show diff stats
test/unit/person_notifier_test.rb
... ... @@ -17,8 +17,10 @@ class PersonNotifierTest < ActiveSupport::TestCase
17 17 @member.save!
18 18 @community = fast_create(Community)
19 19 @community.add_member(@admin)
20   - @article = fast_create(TextileArticle, :name => 'Article test', :profile_id => @community.id, :notify_comments => true)
21   - Delayed::Job.destroy_all
  20 + @article = fast_create(TextileArticle, :name => 'Article test', :profile_id => @community.id, :notify_comments => false)
  21 + Delayed::Job.delete_all
  22 + notify
  23 + ActionMailer::Base.deliveries = []
22 24 end
23 25  
24 26 should 'deliver mail to community members' do
... ... @@ -36,11 +38,9 @@ class PersonNotifierTest < ActiveSupport::TestCase
36 38 end
37 39  
38 40 should 'do not send mail to people not joined to community' do
39   - ActionMailer::Base.deliveries = []
40 41 Comment.create!(:author => @admin, :title => 'test comment 2', :body => 'body 2!', :source => @article)
41 42 notify
42   - sent = ActionMailer::Base.deliveries.first
43   - assert !sent
  43 + assert ActionMailer::Base.deliveries.blank?
44 44 end
45 45  
46 46 should 'display author name in delivered mail' do
... ... @@ -63,15 +63,15 @@ class PersonNotifierTest < ActiveSupport::TestCase
63 63 should 'update last notification date' do
64 64 Comment.create!(:author => @admin, :title => 'test comment 2', :body => 'body 2!', :source => @article)
65 65 @community.add_member(@member)
66   - assert_equal nil, @member.last_notification
  66 + initial_notification = @member.last_notification
67 67 notify
68   - assert @member.last_notification
  68 + assert @member.last_notification > initial_notification
69 69 end
70 70  
71 71 should 'reschedule after notification' do
72 72 Comment.create!(:author => @admin, :title => 'test comment 2', :body => 'body 2!', :source => @article)
73 73 @community.add_member(@member)
74   - assert_equal nil, @member.last_notification
  74 + assert PersonNotifier::NotifyJob.find(@member.id).blank?
75 75 notify
76 76 assert PersonNotifier::NotifyJob.find(@member.id)
77 77 end
... ... @@ -206,7 +206,6 @@ class PersonNotifierTest < ActiveSupport::TestCase
206 206 end
207 207  
208 208 def notify
209   - ActionTracker::Record.all.map{|action| Person.notify_activity(action)}
210 209 process_delayed_job_queue
211 210 @member.notifier.notify
212 211 end
... ...