Commit 4d031bf1beeb7149718fa8b64860089546c1bfcc
1 parent
73abf8b8
Exists in
profile_api_improvements
and in
1 other branch
recent_activities: displays only action trackers on block
The profile activities returns action trackers and scraps, but the scraps should not be displayed on recent activities block. Only the action tracker records Related to merge request !972
Showing
2 changed files
with
18 additions
and
1 deletions
Show diff stats
plugins/recent_activities/lib/recent_activities_plugin/activities_block.rb
@@ -7,7 +7,8 @@ class RecentActivitiesPlugin::ActivitiesBlock < Block | @@ -7,7 +7,8 @@ class RecentActivitiesPlugin::ActivitiesBlock < Block | ||
7 | end | 7 | end |
8 | 8 | ||
9 | def activities | 9 | def activities |
10 | - list = self.limit.nil? ? owner.activities : owner.activities.limit(self.get_limit) | 10 | + activities = owner.activities.where(activity_type: ActionTracker::Record.to_s) |
11 | + list = self.limit.nil? ? activities : activities.limit(self.get_limit) | ||
11 | list.map(&:activity) | 12 | list.map(&:activity) |
12 | end | 13 | end |
13 | 14 |
plugins/recent_activities/test/unit/recent_activities_block_test.rb
@@ -36,6 +36,22 @@ class RecentActivitiesBlockTest < ActiveSupport::TestCase | @@ -36,6 +36,22 @@ class RecentActivitiesBlockTest < ActiveSupport::TestCase | ||
36 | 36 | ||
37 | assert_equal [a2].map(&:id), block.activities.map(&:id) | 37 | assert_equal [a2].map(&:id), block.activities.map(&:id) |
38 | end | 38 | end |
39 | + | ||
40 | + should 'return only action tracker records as activities' do | ||
41 | + profile = create_user('testuser').person | ||
42 | + friend = create_user('friend').person | ||
43 | + scrap = create(Scrap, defaults_for_scrap(sender: friend, receiver: profile)) | ||
44 | + a1 = fast_create(ActionTracker::Record, user_id: profile.id, created_at: Time.now, updated_at: Time.now) | ||
45 | + a2 = fast_create(ActionTracker::Record, user_id: profile.id, created_at: Time.now, updated_at: Time.now) | ||
46 | + ProfileActivity.create! profile_id: profile.id, activity: a1 | ||
47 | + ProfileActivity.create! profile_id: profile.id, activity: a2 | ||
48 | + | ||
49 | + block = RecentActivitiesPlugin::ActivitiesBlock.new | ||
50 | + block.stubs(:owner).returns(profile) | ||
51 | + | ||
52 | + assert_equal [a2, a1, scrap], block.owner.activities.map(&:activity) | ||
53 | + assert_equal [a2, a1], block.activities | ||
54 | + end | ||
39 | end | 55 | end |
40 | 56 | ||
41 | require 'boxes_helper' | 57 | require 'boxes_helper' |