[Git][noosfero/noosfero][stable-1.7] Merge branch 'order_friends' into 'master'

Rodrigo Souto gitlab at mg.gitlab.com
Tue Jan 31 18:36:20 BRST 2017


Rodrigo Souto pushed to branch stable-1.7 at Noosfero / noosfero


Commits:
70854a61 by Rodrigo Souto at 2017-01-31T20:36:16+00:00
Merge branch 'order_friends' into 'master'

Orders friends list alphabetically

Closes #243

See merge request !1103
- - - - -


4 changed files:

- app/controllers/my_profile/friends_controller.rb
- app/controllers/public/profile_controller.rb
- test/functional/friends_controller_test.rb
- test/functional/profile_controller_test.rb


Changes:

=====================================
app/controllers/my_profile/friends_controller.rb
=====================================
--- a/app/controllers/my_profile/friends_controller.rb
+++ b/app/controllers/my_profile/friends_controller.rb
@@ -5,7 +5,8 @@ class FriendsController < MyProfileController
   def index
     @suggestions = profile.suggested_profiles.of_person.enabled.includes(:suggestion).limit(per_page)
     if is_cache_expired?(profile.manage_friends_cache_key(params))
-      @friends = profile.friends.paginate(:per_page => per_page, :page => params[:npage])
+      @friends = profile.friends.order(:name)
+        .paginate(:per_page => per_page, :page => params[:npage])
     end
   end
 


=====================================
app/controllers/public/profile_controller.rb
=====================================
--- a/app/controllers/public/profile_controller.rb
+++ b/app/controllers/public/profile_controller.rb
@@ -68,7 +68,9 @@ class ProfileController < PublicController
 
   def friends
     if is_cache_expired?(profile.friends_cache_key(params))
-      @friends = profile.friends.includes(relations_to_include).paginate(:per_page => per_page, :page => params[:npage], :total_entries => profile.friends.count)
+      @friends = profile.friends.order(:name).includes(relations_to_include)
+        .paginate(:per_page => per_page, :page => params[:npage],
+                  :total_entries => profile.friends.count)
     end
   end
 


=====================================
test/functional/friends_controller_test.rb
=====================================
--- a/test/functional/friends_controller_test.rb
+++ b/test/functional/friends_controller_test.rb
@@ -13,11 +13,15 @@ class FriendsControllerTest < ActionController::TestCase
   end
   attr_accessor :profile, :friend
 
-  should 'list friends' do
+  should 'list friends in alphabetical order' do
+    profile.add_friend(create_user('angela').person)
+    profile.add_friend(create_user('paula').person)
+    profile.add_friend(create_user('jose').person)
+
     get :index
     assert_response :success
     assert_template 'index'
-    assert assigns(:friends)
+    assert_equal assigns(:friends).map(&:name), ['angela', 'jose', 'paula']
   end
 
   should 'confirm removal of friend' do


=====================================
test/functional/profile_controller_test.rb
=====================================
--- a/test/functional/profile_controller_test.rb
+++ b/test/functional/profile_controller_test.rb
@@ -12,12 +12,15 @@ class ProfileControllerTest < ActionController::TestCase
   end
   attr_reader :profile
 
-  should 'list friends' do
-    get :friends
+  should 'list friends in alphabetical order' do
+    profile.add_friend(create_user('angela').person)
+    profile.add_friend(create_user('paula').person)
+    profile.add_friend(create_user('jose').person)
 
+    get :friends
     assert_response :success
     assert_template 'friends'
-    assert assigns(:friends)
+    assert_equal assigns(:friends).map(&:name), ['angela', 'jose', 'paula']
   end
 
   should 'remove person from article followers when unfollow' do



View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/70854a6171140d0b9f8a7c81924c0a3fd68da13f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170131/62c7305d/attachment-0001.html>


More information about the Noosfero-dev mailing list