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