Commit 8c2f76568ee8e06d4de4aa885a9a83b3dec04601
1 parent
60b69b3c
Exists in
master
and in
8 other branches
Grouping activities of images upload
Also, removed comments from images on profile, because now the gallery is the target of activity (ActionItem1826)
Showing
4 changed files
with
21 additions
and
23 deletions
Show diff stats
app/models/uploaded_file.rb
| ... | ... | @@ -8,7 +8,7 @@ class UploadedFile < Article |
| 8 | 8 | _('File') |
| 9 | 9 | end |
| 10 | 10 | |
| 11 | - track_actions :upload_image, :after_create, :keep_params => ["view_url", "thumbnail_path", "parent.url", "parent.name"], :if => Proc.new { |a| a.published? && a.image? && !a.parent.nil? && a.parent.gallery? }, :custom_target => :action_tracker_target | |
| 11 | + track_actions :upload_image, :after_create, :keep_params => ["view_url", "thumbnail_path", "parent.url", "parent.name"], :if => Proc.new { |a| a.published? && a.image? && !a.parent.nil? && a.parent.gallery? }, :custom_target => :parent | |
| 12 | 12 | |
| 13 | 13 | include ShortFilename |
| 14 | 14 | |
| ... | ... | @@ -144,9 +144,4 @@ class UploadedFile < Article |
| 144 | 144 | def uploaded_file? |
| 145 | 145 | true |
| 146 | 146 | end |
| 147 | - | |
| 148 | - def action_tracker_target | |
| 149 | - self | |
| 150 | - end | |
| 151 | - | |
| 152 | 147 | end | ... | ... |
app/views/profile/_upload_image.rhtml
| ... | ... | @@ -6,15 +6,9 @@ |
| 6 | 6 | <p class='profile-activity-text'><%= link_to activity.user.name, activity.user.url %> <%= describe activity %></p> |
| 7 | 7 | <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> |
| 8 | 8 | <div class='profile-wall-actions'> |
| 9 | - <%= link_to(s_('profile|Comment'), '#', { :class => 'focus-on-comment'}) unless activity.get_view_url.size == 1 %> | |
| 10 | 9 | <%= link_to_remote(content_tag(:span, _('Remove')), :confirm => _('Are you sure?'), :url =>{:action => 'remove_activity', :activity_id => activity.id}, :update => "profile-activity-item-#{activity.id}") if logged_in? && current_person == @profile %> |
| 11 | 10 | </div> |
| 12 | 11 | </div> |
| 13 | 12 | </div> |
| 14 | 13 | <div title='<%= activity.target.class.short_description %>' class='profile-activity-icon icon-new icon-newgallery'></div> |
| 15 | - | |
| 16 | -<% if activity.get_view_url.size == 1 %> | |
| 17 | - <%= render :partial => 'profile_comments', :locals => { :activity => activity, :tab_action => tab_action } %> | |
| 18 | -<% end %> | |
| 19 | - | |
| 20 | 14 | <br/> | ... | ... |
test/unit/action_tracker_notification_test.rb
| ... | ... | @@ -78,14 +78,13 @@ class ActionTrackerNotificationTest < ActiveSupport::TestCase |
| 78 | 78 | |
| 79 | 79 | should "have comments through action_tracker" do |
| 80 | 80 | person = fast_create(Person) |
| 81 | - community = fast_create(Community) | |
| 82 | - community.add_member(person) | |
| 83 | - activity = ActionTracker::Record.last | |
| 81 | + friend = fast_create(Person) | |
| 82 | + person.add_friend(friend) | |
| 84 | 83 | process_delayed_job_queue |
| 85 | - notification = ActionTrackerNotification.last | |
| 84 | + activity = ActionTracker::Record.find_last_by_verb 'new_friendship' | |
| 85 | + notification = ActionTrackerNotification.find_by_action_tracker_id activity.id | |
| 86 | 86 | |
| 87 | 87 | comment = create(Comment, :source => activity, :author => person) |
| 88 | - | |
| 89 | 88 | assert_equal activity.comments, notification.comments |
| 90 | 89 | end |
| 91 | 90 | ... | ... |
test/unit/uploaded_file_test.rb
| ... | ... | @@ -22,7 +22,7 @@ class UploadedFileTest < ActiveSupport::TestCase |
| 22 | 22 | f = UploadedFile.new |
| 23 | 23 | f.expects(:content_type).returns('application/pdf') |
| 24 | 24 | assert_equal 'application/pdf', f.mime_type |
| 25 | - end | |
| 25 | + end | |
| 26 | 26 | |
| 27 | 27 | should 'provide proper description' do |
| 28 | 28 | assert_kind_of String, UploadedFile.description |
| ... | ... | @@ -330,11 +330,21 @@ class UploadedFileTest < ActiveSupport::TestCase |
| 330 | 330 | assert_equal 'hello_world.php.txt', file.filename |
| 331 | 331 | end |
| 332 | 332 | |
| 333 | - should 'use itself as target for action tracker' do | |
| 334 | - p = fast_create(Gallery, :profile_id => @profile.id) | |
| 335 | - f = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => p, :profile => @profile) | |
| 336 | - ta = f.activity | |
| 337 | - assert_equal f, ta.target | |
| 333 | + should 'use gallery as target for action tracker' do | |
| 334 | + gallery = fast_create(Gallery, :profile_id => profile.id) | |
| 335 | + image = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => gallery, :profile => profile) | |
| 336 | + activity = ActionTracker::Record.find_last_by_verb 'upload_image' | |
| 337 | + assert_equal gallery, activity.target | |
| 338 | + end | |
| 339 | + | |
| 340 | + should 'group trackers activity of image\'s upload' do | |
| 341 | + gallery = fast_create(Gallery, :profile_id => profile.id) | |
| 342 | + | |
| 343 | + image1 = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => gallery, :profile => profile) | |
| 344 | + assert_equal 1, ActionTracker::Record.find_all_by_verb('upload_image').count | |
| 345 | + | |
| 346 | + image2 = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg'), :parent => gallery, :profile => profile) | |
| 347 | + assert_equal 1, ActionTracker::Record.find_all_by_verb('upload_image').count | |
| 338 | 348 | end |
| 339 | 349 | |
| 340 | 350 | end | ... | ... |