Commit 3da8991d18aed857ac9a2563c21af9aaa2914fbe
Exists in
master
and in
22 other branches
Merge commit 'refs/merge-requests/341' of git://gitorious.org/noosfero/noosfero …
…into merge-requests/341
Showing
2 changed files
with
26 additions
and
1 deletions
Show diff stats
lib/notify_activity_to_profiles_job.rb
| ... | ... | @@ -10,7 +10,7 @@ class NotifyActivityToProfilesJob < Struct.new(:tracked_action_id) |
| 10 | 10 | return unless ActionTracker::Record.exists?(tracked_action_id) |
| 11 | 11 | tracked_action = ActionTracker::Record.find(tracked_action_id) |
| 12 | 12 | target = tracked_action.target |
| 13 | - if target.is_a?(Community) && NOTIFY_ONLY_COMMUNITY.include?(tracked_action.verb) | |
| 13 | + if target.is_a?(Community) && ( NOTIFY_ONLY_COMMUNITY.include?(tracked_action.verb) || ! target.public_profile ) | |
| 14 | 14 | ActionTrackerNotification.create(:profile_id => target.id, :action_tracker_id => tracked_action.id) |
| 15 | 15 | return |
| 16 | 16 | end | ... | ... |
test/unit/notify_activity_to_profiles_job_test.rb
| ... | ... | @@ -88,6 +88,31 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase |
| 88 | 88 | end |
| 89 | 89 | end |
| 90 | 90 | |
| 91 | + should 'notify only the community if it is private' do | |
| 92 | + person = fast_create(Person) | |
| 93 | + private_community = fast_create(Community, :public_profile => false) | |
| 94 | + action_tracker = fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => person.id, :target_type => 'Profile', :target_id => private_community.id, :verb => 'create_article') | |
| 95 | + assert !NotifyActivityToProfilesJob::NOTIFY_ONLY_COMMUNITY.include?(action_tracker.verb) | |
| 96 | + p1, p2, m1, m2 = fast_create(Person), fast_create(Person), fast_create(Person), fast_create(Person) | |
| 97 | + fast_create(Friendship, :person_id => person.id, :friend_id => p1.id) | |
| 98 | + fast_create(Friendship, :person_id => person.id, :friend_id => p2.id) | |
| 99 | + fast_create(RoleAssignment, :accessor_id => m1.id, :role_id => 3, :resource_id => private_community.id) | |
| 100 | + fast_create(RoleAssignment, :accessor_id => m2.id, :role_id => 3, :resource_id => private_community.id) | |
| 101 | + ActionTrackerNotification.delete_all | |
| 102 | + job = NotifyActivityToProfilesJob.new(action_tracker.id) | |
| 103 | + job.perform | |
| 104 | + process_delayed_job_queue | |
| 105 | + | |
| 106 | + assert_equal 1, ActionTrackerNotification.count | |
| 107 | + [person, p1, p2, m1, m2].each do |profile| | |
| 108 | + notification = ActionTrackerNotification.find_by_profile_id profile.id | |
| 109 | + assert notification.nil? | |
| 110 | + end | |
| 111 | + | |
| 112 | + notification = ActionTrackerNotification.find_by_profile_id private_community.id | |
| 113 | + assert_equal action_tracker, notification.action_tracker | |
| 114 | + end | |
| 115 | + | |
| 91 | 116 | should 'not notify the community tracking join_community verb' do |
| 92 | 117 | person = fast_create(Person) |
| 93 | 118 | community = fast_create(Community) | ... | ... |