Commit 9cd1cb0891aa32c9a0f2597f4d8c9b1ea811701f
1 parent
38f51804
fixes typo and adds a test
Showing
2 changed files
with
22 additions
and
4 deletions
Show diff stats
app/jobs/notify_mentioned_users_job.rb
| @@ -19,7 +19,7 @@ class NotifyMentionedUsersJob < Struct.new(:tracked_action_id) | @@ -19,7 +19,7 @@ class NotifyMentionedUsersJob < Struct.new(:tracked_action_id) | ||
| 19 | people_identifiers -= [mention_creator.identifier] | 19 | people_identifiers -= [mention_creator.identifier] |
| 20 | 20 | ||
| 21 | followers = mention_creator.followers | 21 | followers = mention_creator.followers |
| 22 | - people_idenfifiers -= followers.map(&:identifier) if (followers.present? && remove_followers) | 22 | + people_identifiers -= followers.map(&:identifier) if (followers.present? && remove_followers) |
| 23 | 23 | ||
| 24 | return if people_identifiers.empty? | 24 | return if people_identifiers.empty? |
| 25 | 25 |
test/unit/notify_mentioned_users_job_test.rb
| @@ -88,9 +88,27 @@ class NotifyMentionedUsersJobTest < ActiveSupport::TestCase | @@ -88,9 +88,27 @@ class NotifyMentionedUsersJobTest < ActiveSupport::TestCase | ||
| 88 | end | 88 | end |
| 89 | 89 | ||
| 90 | should 'not create notification from mention if the mentioned users are also followers' do | 90 | should 'not create notification from mention if the mentioned users are also followers' do |
| 91 | - end | 91 | + circle = Circle.create!(:person=> @person3, :name => "Zombies", :profile_type => 'Person') |
| 92 | + @person3.follow(@person1, circle) | ||
| 93 | + process_delayed_job_queue | ||
| 94 | + ActionTrackerNotification.delete_all | ||
| 92 | 95 | ||
| 93 | - should 'not show notification from mention on the authors wall' do | ||
| 94 | - end | 96 | + s = Scrap.new |
| 97 | + s.sender = @person1 | ||
| 98 | + s.receiver = @person2 | ||
| 99 | + s.content = "Run @third, run!!!" | ||
| 100 | + s.save! | ||
| 95 | 101 | ||
| 102 | + action_tracker = ActionTracker::Record.create(:user => @person1, :target => s, | ||
| 103 | + :verb => 'notify_mentioned_users', | ||
| 104 | + :params => {"content" => s.content, "url"=>s.receiver.url}) | ||
| 105 | + | ||
| 106 | + job = NotifyMentionedUsersJob.new(action_tracker.id) | ||
| 107 | + job.perform | ||
| 108 | + process_delayed_job_queue | ||
| 109 | + | ||
| 110 | + assert_equal 2, ActionTrackerNotification.count | ||
| 111 | + assert_not_includes ActionTrackerNotification.all.map{|a|a.action_tracker.verb}, "notify_mentioned_users" | ||
| 112 | + assert_equal ActionTrackerNotification.all.map{|a|a.action_tracker.verb}, ["leave_scrap","leave_scrap"] | ||
| 113 | + end | ||
| 96 | end | 114 | end |