From c941417da22b7c35b3c7b7357a7ed774a8c3c18f Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Wed, 15 Sep 2010 18:49:13 -0300 Subject: [PATCH] Removed notify_activity_job --- lib/notify_activity_job.rb | 7 ------- lib/notify_activity_to_profiles_job.rb | 4 ++-- test/unit/notify_activity_job_test.rb | 18 ------------------ test/unit/notify_activity_to_profiles_job_test.rb | 6 +++++- 4 files changed, 7 insertions(+), 28 deletions(-) delete mode 100644 lib/notify_activity_job.rb delete mode 100644 test/unit/notify_activity_job_test.rb diff --git a/lib/notify_activity_job.rb b/lib/notify_activity_job.rb deleted file mode 100644 index 9ce4d54..0000000 --- a/lib/notify_activity_job.rb +++ /dev/null @@ -1,7 +0,0 @@ -class NotifyActivityJob < Struct.new(:tracked_action_id, :profile_id) - def perform - tracked_action = ActionTracker::Record.find(tracked_action_id) - profile = Profile.find(profile_id) - ActionTrackerNotification.create(:action_tracker => tracked_action, :profile => profile) - end -end diff --git a/lib/notify_activity_to_profiles_job.rb b/lib/notify_activity_to_profiles_job.rb index 9ce20e0..003eae6 100644 --- a/lib/notify_activity_to_profiles_job.rb +++ b/lib/notify_activity_to_profiles_job.rb @@ -3,12 +3,12 @@ class NotifyActivityToProfilesJob < Struct.new(:tracked_action_id, :target_profi profile = Profile.find(target_profile_id) unless target_profile_id.nil? tracked_action = ActionTracker::Record.find(tracked_action_id) tracked_action.user.each_friend do |friend| - Delayed::Job.enqueue NotifyActivityJob.new(tracked_action_id, friend.id) + ActionTrackerNotification.create(:action_tracker => tracked_action, :profile => friend) end if profile.is_a?(Community) profile.each_member do |member| next if member == tracked_action.user - Delayed::Job.enqueue NotifyActivityJob.new(tracked_action_id, member.id) + ActionTrackerNotification.create(:action_tracker => tracked_action, :profile => member) end ActionTrackerNotification.create(:action_tracker => tracked_action, :profile => profile) end diff --git a/test/unit/notify_activity_job_test.rb b/test/unit/notify_activity_job_test.rb deleted file mode 100644 index 77bb649..0000000 --- a/test/unit/notify_activity_job_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class NotifyActivityJobTest < ActiveSupport::TestCase - - should 'create the ActionTrackerNotification' do - action_tracker = fast_create(ActionTracker::Record) - profile = fast_create(Profile) - count = ActionTrackerNotification.count - job = NotifyActivityJob.new(action_tracker.id, profile.id) - job.perform - - assert_equal count + 1, ActionTrackerNotification.count - last = ActionTrackerNotification.last - assert_equal action_tracker, last.action_tracker - assert_equal profile, last.profile - end - -end diff --git a/test/unit/notify_activity_to_profiles_job_test.rb b/test/unit/notify_activity_to_profiles_job_test.rb index 9eb5225..d1f6a3d 100644 --- a/test/unit/notify_activity_to_profiles_job_test.rb +++ b/test/unit/notify_activity_to_profiles_job_test.rb @@ -15,7 +15,11 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase job = NotifyActivityToProfilesJob.new(action_tracker.id, community.id) job.perform process_delayed_job_queue - assert_equal 5, ActionTrackerNotification.count + + [community, p1, p2, m1, m2].each do |profile| + notification = ActionTrackerNotification.find_by_profile_id profile.id + assert_equal action_tracker, notification.action_tracker + end end end -- libgit2 0.21.2