Commit 18df09eb8e2f9d3c5a278ebd1ec714d8733fa2f4

Authored by Rodrigo Souto
1 parent c12aaa50

rails3: fix notify_activity_to_proiles_job tests

app/models/action_tracker_notification.rb
@@ -8,6 +8,8 @@ class ActionTrackerNotification < ActiveRecord::Base @@ -8,6 +8,8 @@ class ActionTrackerNotification < ActiveRecord::Base
8 validates_presence_of :profile_id, :action_tracker_id 8 validates_presence_of :profile_id, :action_tracker_id
9 validates_uniqueness_of :action_tracker_id, :scope => :profile_id 9 validates_uniqueness_of :action_tracker_id, :scope => :profile_id
10 10
  11 + attr_accessible :profile_id, :action_tracker_id
  12 +
11 end 13 end
12 14
13 ActionTracker::Record.has_many :action_tracker_notifications, :class_name => 'ActionTrackerNotification', :foreign_key => 'action_tracker_id', :dependent => :destroy 15 ActionTracker::Record.has_many :action_tracker_notifications, :class_name => 'ActionTrackerNotification', :foreign_key => 'action_tracker_id', :dependent => :destroy
lib/notify_activity_to_profiles_job.rb
@@ -9,6 +9,7 @@ class NotifyActivityToProfilesJob < Struct.new(:tracked_action_id) @@ -9,6 +9,7 @@ class NotifyActivityToProfilesJob < Struct.new(:tracked_action_id)
9 def perform 9 def perform
10 return unless ActionTracker::Record.exists?(tracked_action_id) 10 return unless ActionTracker::Record.exists?(tracked_action_id)
11 tracked_action = ActionTracker::Record.find(tracked_action_id) 11 tracked_action = ActionTracker::Record.find(tracked_action_id)
  12 + return unless tracked_action.user.present?
12 target = tracked_action.target 13 target = tracked_action.target
13 if target.is_a?(Community) && NOTIFY_ONLY_COMMUNITY.include?(tracked_action.verb) 14 if target.is_a?(Community) && NOTIFY_ONLY_COMMUNITY.include?(tracked_action.verb)
14 ActionTrackerNotification.create(:profile_id => target.id, :action_tracker_id => tracked_action.id) 15 ActionTrackerNotification.create(:profile_id => target.id, :action_tracker_id => tracked_action.id)