Commit c941417da22b7c35b3c7b7357a7ed774a8c3c18f
Committed by
Antonio Terceiro
1 parent
a2a45854
Exists in
master
and in
29 other branches
Removed notify_activity_job
(ActionItem1303)
Showing
4 changed files
with
7 additions
and
28 deletions
Show diff stats
lib/notify_activity_job.rb
| @@ -1,7 +0,0 @@ | @@ -1,7 +0,0 @@ | ||
| 1 | -class NotifyActivityJob < Struct.new(:tracked_action_id, :profile_id) | ||
| 2 | - def perform | ||
| 3 | - tracked_action = ActionTracker::Record.find(tracked_action_id) | ||
| 4 | - profile = Profile.find(profile_id) | ||
| 5 | - ActionTrackerNotification.create(:action_tracker => tracked_action, :profile => profile) | ||
| 6 | - end | ||
| 7 | -end |
lib/notify_activity_to_profiles_job.rb
| @@ -3,12 +3,12 @@ class NotifyActivityToProfilesJob < Struct.new(:tracked_action_id, :target_profi | @@ -3,12 +3,12 @@ class NotifyActivityToProfilesJob < Struct.new(:tracked_action_id, :target_profi | ||
| 3 | profile = Profile.find(target_profile_id) unless target_profile_id.nil? | 3 | profile = Profile.find(target_profile_id) unless target_profile_id.nil? |
| 4 | tracked_action = ActionTracker::Record.find(tracked_action_id) | 4 | tracked_action = ActionTracker::Record.find(tracked_action_id) |
| 5 | tracked_action.user.each_friend do |friend| | 5 | tracked_action.user.each_friend do |friend| |
| 6 | - Delayed::Job.enqueue NotifyActivityJob.new(tracked_action_id, friend.id) | 6 | + ActionTrackerNotification.create(:action_tracker => tracked_action, :profile => friend) |
| 7 | end | 7 | end |
| 8 | if profile.is_a?(Community) | 8 | if profile.is_a?(Community) |
| 9 | profile.each_member do |member| | 9 | profile.each_member do |member| |
| 10 | next if member == tracked_action.user | 10 | next if member == tracked_action.user |
| 11 | - Delayed::Job.enqueue NotifyActivityJob.new(tracked_action_id, member.id) | 11 | + ActionTrackerNotification.create(:action_tracker => tracked_action, :profile => member) |
| 12 | end | 12 | end |
| 13 | ActionTrackerNotification.create(:action_tracker => tracked_action, :profile => profile) | 13 | ActionTrackerNotification.create(:action_tracker => tracked_action, :profile => profile) |
| 14 | end | 14 | end |
test/unit/notify_activity_job_test.rb
| @@ -1,18 +0,0 @@ | @@ -1,18 +0,0 @@ | ||
| 1 | -require File.dirname(__FILE__) + '/../test_helper' | ||
| 2 | - | ||
| 3 | -class NotifyActivityJobTest < ActiveSupport::TestCase | ||
| 4 | - | ||
| 5 | - should 'create the ActionTrackerNotification' do | ||
| 6 | - action_tracker = fast_create(ActionTracker::Record) | ||
| 7 | - profile = fast_create(Profile) | ||
| 8 | - count = ActionTrackerNotification.count | ||
| 9 | - job = NotifyActivityJob.new(action_tracker.id, profile.id) | ||
| 10 | - job.perform | ||
| 11 | - | ||
| 12 | - assert_equal count + 1, ActionTrackerNotification.count | ||
| 13 | - last = ActionTrackerNotification.last | ||
| 14 | - assert_equal action_tracker, last.action_tracker | ||
| 15 | - assert_equal profile, last.profile | ||
| 16 | - end | ||
| 17 | - | ||
| 18 | -end |
test/unit/notify_activity_to_profiles_job_test.rb
| @@ -15,7 +15,11 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase | @@ -15,7 +15,11 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase | ||
| 15 | job = NotifyActivityToProfilesJob.new(action_tracker.id, community.id) | 15 | job = NotifyActivityToProfilesJob.new(action_tracker.id, community.id) |
| 16 | job.perform | 16 | job.perform |
| 17 | process_delayed_job_queue | 17 | process_delayed_job_queue |
| 18 | - assert_equal 5, ActionTrackerNotification.count | 18 | + |
| 19 | + [community, p1, p2, m1, m2].each do |profile| | ||
| 20 | + notification = ActionTrackerNotification.find_by_profile_id profile.id | ||
| 21 | + assert_equal action_tracker, notification.action_tracker | ||
| 22 | + end | ||
| 19 | end | 23 | end |
| 20 | 24 | ||
| 21 | end | 25 | end |