[Git][noosfero/noosfero][master] 2 commits: Fix the display of comments on the networks tab

Rodrigo Souto gitlab at mg.gitlab.com
Thu Jun 8 09:30:03 BRT 2017


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
cab6631a by pedrodelyra at 2017-06-06T11:25:44-03:00
Fix the display of comments on the networks tab

- - - - -
5fb8e093 by Rodrigo Souto at 2017-06-08T12:29:28+00:00
Merge branch 'fix-network-tab-comments' into 'master'

Fix the display of comments on the networks tab

Closes #255

See merge request !1230
- - - - -


4 changed files:

- app/controllers/public/profile_controller.rb
- app/views/profile/_more_comments.html.erb
- app/views/profile/_profile_comments.html.erb
- test/functional/profile_controller_test.rb


Changes:

=====================================
app/controllers/public/profile_controller.rb
=====================================
--- a/app/controllers/public/profile_controller.rb
+++ b/app/controllers/public/profile_controller.rb
@@ -318,14 +318,14 @@ class ProfileController < PublicController
     no_more_pages = comments_count <= comment_page * comments_per_page
 
     render :update do |page|
-      page.insert_html :bottom, 'profile-wall-activities-comments-'+params[:activity],
+      page.insert_html :bottom, "profile-#{params[:tab_action]}-activities-comments-#{params[:activity]}",
         :partial => 'comment', :collection => activity.comments.flatten.paginate(:per_page => comments_per_page, :page => comment_page)
 
       if no_more_pages
-        page.remove 'profile-wall-activities-comments-more-'+params[:activity]
+        page.remove "profile-#{params[:tab_action]}-activities-comments-more-#{params[:activity]}"
       else
-        page.replace_html 'profile-wall-activities-comments-more-'+params[:activity],
-          :partial => 'more_comments', :locals => {:activity => activity, :comment_page => comment_page}
+        page.replace_html "profile-#{params[:tab_action]}-activities-comments-more-#{params[:activity]}",
+          :partial => 'more_comments', :locals => {activity: activity, comment_page: comment_page, tab_action: params[:tab_action]}
       end
     end
   end


=====================================
app/views/profile/_more_comments.html.erb
=====================================
--- a/app/views/profile/_more_comments.html.erb
+++ b/app/views/profile/_more_comments.html.erb
@@ -1,3 +1,4 @@
 <div class='view-more-comments'>
-  <%= link_to(_('More'), :profile => @profile.identifier, :controller => 'profile', :action => 'more_comments', :activity => activity, :comment_page => (comment_page + 1)) %>
+  <%= link_to(_('More'), profile: @profile.identifier, controller: 'profile', action: 'more_comments',
+                         activity: activity, comment_page: (comment_page + 1), tab_action: tab_action) %>
 </div>


=====================================
app/views/profile/_profile_comments.html.erb
=====================================
--- a/app/views/profile/_profile_comments.html.erb
+++ b/app/views/profile/_profile_comments.html.erb
@@ -1,11 +1,12 @@
 <hr />
 
-<ul id="profile-wall-activities-comments-<%= activity.id %>" class="profile-wall-activities-comments"  >
+<ul id=<%= "profile-#{tab_action}-activities-comments-#{activity.id}"%> class=<%= "profile-wall-activities-comments" %> >
 </ul>
 <% if activity.comments_count > 0 %>
-<div id="profile-wall-activities-comments-more-<%= activity.id %>" class="profile-wall-activities-comments" >
+  <div id=<%= "profile-#{tab_action}-activities-comments-more-#{activity.id}" %> class=<%= "profile-wall-activities-comments" %> >
   <div class='view-all-comments icon-chat'>
-     <%= link_to(n_('View comment', "View all %s comments".html_safe, activity.comments_count) % activity.comments_count, :profile => profile.identifier, :controller => 'profile', :action => 'more_comments', :activity => activity, :comment_page => (1)) %>
+    <%= link_to(n_('View comment', "View all %s comments".html_safe, activity.comments_count) % activity.comments_count,
+                profile: profile.identifier, controller: 'profile', action: 'more_comments', activity: activity, comment_page: 1, tab_action: tab_action) %>
   </div>
 </div>
 <% end %>


=====================================
test/functional/profile_controller_test.rb
=====================================
--- a/test/functional/profile_controller_test.rb
+++ b/test/functional/profile_controller_test.rb
@@ -2097,6 +2097,23 @@ class ProfileControllerTest < ActionController::TestCase
     assert_tag :tag => 'div', :attributes => {:id => 'profile-network'}
   end
 
+  should 'display comments of an article in network activities tab' do
+    login_as(profile.identifier)
+    article = TextArticle.create!(profile: profile, name: 'An article about free software')
+    20.times do |i|
+      comment = fast_create(Comment, source_id: article, title: "Comment #{i}",
+                                     body: "lalala", created_at: Time.now)
+    end
+    assert_equal 20, article.comments.count
+    activity = ActionTracker::Record.last
+    xhr :get, :more_comments, profile: profile.identifier, activity: activity.id, comment_page: 1, tab_action: 'network'
+    assert_response :success
+    assert_template '_comment'
+    assert_select_rjs :insert_html, :bottom, "profile-network-activities-comments-#{activity.id}" do
+      assert_select 'li', 5 # 5 comments per page
+    end
+  end
+
   should 'not filter any activity if the user is an environment admin' do
     admin = create_user('env-admin').person
     env = @profile.environment



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/3b8144214d1d0a6ab0e8da542e83777320b23305...5fb8e093b7343a32dc645377635dbf62defdac95

---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/3b8144214d1d0a6ab0e8da542e83777320b23305...5fb8e093b7343a32dc645377635dbf62defdac95
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170608/119e8d95/attachment-0001.html>


More information about the Noosfero-dev mailing list