[Git][noosfero/noosfero][master] 3 commits: Making friends only relate to a person

Rodrigo Souto gitlab at mg.gitlab.com
Tue Oct 30 14:39:57 BRST 2018


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
32773dbb by Alax Alves at 2018-10-15T21:31:09Z
Making friends only relate to a person

- - - - -
62a2e95e by MatheusRich at 2018-10-30T03:00:14Z
Creates before_action to index

- - - - -
ac0e803a by Rodrigo Souto at 2018-10-30T16:39:53Z
Merge branch 'issue-305' into 'master'

Making friends only relate to a person

See merge request noosfero/noosfero!1626
- - - - -


2 changed files:

- app/controllers/my_profile/friends_controller.rb
- test/functional/friends_controller_test.rb


Changes:

=====================================
app/controllers/my_profile/friends_controller.rb
=====================================
@@ -1,6 +1,7 @@
 class FriendsController < MyProfileController
 
   protect 'manage_friends', :profile
+  before_action :is_person?, only: :index
 
   def index
     @suggestions = profile.suggested_profiles.of_person.enabled.includes(:suggestion).limit(per_page)
@@ -53,4 +54,11 @@ class FriendsController < MyProfileController
     self.class.per_page
   end
 
+  private
+
+  def is_person?
+    unless profile.person?
+      render_not_found
+    end
+  end
 end


=====================================
test/functional/friends_controller_test.rb
=====================================
@@ -23,6 +23,19 @@ class FriendsControllerTest < ActionController::TestCase
     assert_equal assigns(:friends).map(&:name), ['angela', 'jose', 'paula']
   end
 
+  should 'only list friends of a person' do
+    login_as :testuser
+    community = fast_create(Community, name: 'my test profile', identifier: 'communitytest')
+    enterprise = fast_create(Enterprise, name: 'my test profile 2', identifier: 'enterprisetest')
+    community.add_admin(profile)
+    enterprise.add_admin(profile)
+
+    [community.identifier, enterprise.identifier].each do |id|
+      get :index, profile: id
+      assert_response :not_found
+    end
+  end
+
   should 'confirm removal of friend' do
     profile.add_friend(friend)
 



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/338007fde27348c47e579f25cb95936a3ac16908...ac0e803a32d17161b254dc2354f690f63e3e98f5

-- 
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/338007fde27348c47e579f25cb95936a3ac16908...ac0e803a32d17161b254dc2354f690f63e3e98f5
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/20181030/d6126fcd/attachment-0001.html>


More information about the Noosfero-dev mailing list