[Git][noosfero/noosfero][master] 2 commits: Orders friends list alphabetically

Rodrigo Souto gitlab at mg.gitlab.com
Mon Jan 30 13:10:57 BRST 2017


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
d3785375 by Gabriel Silva at 2017-01-25T19:45:05+00:00
Orders friends list alphabetically

Signed-off-by: Gabriel Silva <gabriel93.silva at gmail.com>

- - - - -
2fb4a53c by Rodrigo Souto at 2017-01-30T15:10:48+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/compare/309681d06d1817d3af2aa1ec176bbf8d09b65176...2fb4a53cacce13b5bf199e28d0f3244a919911d9
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170130/b1072f6b/attachment-0001.html>


More information about the Noosfero-dev mailing list