Commit 638d29b1f194db6dc4cf84e4b0a4bb37051b29ed
Committed by
Leandro Santos
1 parent
410aa5af
Exists in
send_email_to_admins
and in
5 other branches
get list visible communities, enterprises & people
Showing
4 changed files
with
9 additions
and
5 deletions
Show diff stats
lib/noosfero/api/v1/communities.rb
@@ -49,7 +49,7 @@ module Noosfero | @@ -49,7 +49,7 @@ module Noosfero | ||
49 | end | 49 | end |
50 | 50 | ||
51 | get ':id' do | 51 | get ':id' do |
52 | - community = environment.communities.visible_for_person(current_person).find_by id: params[:id] | 52 | + community = environment.communities.visible..find_by(id: params[:id]) |
53 | present community, :with => Entities::Community, :current_person => current_person | 53 | present community, :with => Entities::Community, :current_person => current_person |
54 | end | 54 | end |
55 | 55 |
lib/noosfero/api/v1/enterprises.rb
@@ -26,7 +26,7 @@ module Noosfero | @@ -26,7 +26,7 @@ module Noosfero | ||
26 | 26 | ||
27 | desc "Return one enterprise by id" | 27 | desc "Return one enterprise by id" |
28 | get ':id' do | 28 | get ':id' do |
29 | - enterprise = environment.enterprises.visible_for_person(current_person).find_by id: params[:id] | 29 | + enterprise = environment.enterprises.visible.find_by(id: params[:id]) |
30 | present enterprise, :with => Entities::Enterprise, :current_person => current_person | 30 | present enterprise, :with => Entities::Enterprise, :current_person => current_person |
31 | end | 31 | end |
32 | 32 |
lib/noosfero/api/v1/people.rb
@@ -46,7 +46,7 @@ module Noosfero | @@ -46,7 +46,7 @@ module Noosfero | ||
46 | 46 | ||
47 | desc "Return the person information" | 47 | desc "Return the person information" |
48 | get ':id' do | 48 | get ':id' do |
49 | - person = environment.people.visible_for_person(current_person).find_by id: params[:id] | 49 | + person = environment.people.visible.find_by(id: params[:id]) |
50 | return not_found! if person.blank? | 50 | return not_found! if person.blank? |
51 | present person, :with => Entities::Person, :current_person => current_person | 51 | present person, :with => Entities::Person, :current_person => current_person |
52 | end | 52 | end |
@@ -87,7 +87,11 @@ module Noosfero | @@ -87,7 +87,11 @@ module Noosfero | ||
87 | 87 | ||
88 | desc "Return the person friends" | 88 | desc "Return the person friends" |
89 | get ':id/friends' do | 89 | get ':id/friends' do |
90 | +<<<<<<< HEAD | ||
90 | person = environment.people.visible_for_person(current_person).find_by id: params[:id] | 91 | person = environment.people.visible_for_person(current_person).find_by id: params[:id] |
92 | +======= | ||
93 | + person = environment.people.visible.find_by_id(params[:id]) | ||
94 | +>>>>>>> get list visible communities, enterprises & people | ||
91 | return not_found! if person.blank? | 95 | return not_found! if person.blank? |
92 | friends = person.friends.visible | 96 | friends = person.friends.visible |
93 | present friends, :with => Entities::Person, :current_person => current_person | 97 | present friends, :with => Entities::Person, :current_person => current_person |
test/api/people_test.rb
@@ -96,12 +96,12 @@ class PeopleTest < ActiveSupport::TestCase | @@ -96,12 +96,12 @@ class PeopleTest < ActiveSupport::TestCase | ||
96 | assert json['person'].blank? | 96 | assert json['person'].blank? |
97 | end | 97 | end |
98 | 98 | ||
99 | - should 'not get private people without permission' do | 99 | + should 'get private people' do |
100 | private_person = fast_create(Person, :public_profile => false) | 100 | private_person = fast_create(Person, :public_profile => false) |
101 | 101 | ||
102 | get "/api/v1/people/#{private_person.id}?#{params.to_query}" | 102 | get "/api/v1/people/#{private_person.id}?#{params.to_query}" |
103 | json = JSON.parse(last_response.body) | 103 | json = JSON.parse(last_response.body) |
104 | - assert json['person'].blank? | 104 | + assert_equal json['person']['id'], private_person.id |
105 | end | 105 | end |
106 | 106 | ||
107 | should 'get private person for friends' do | 107 | should 'get private person for friends' do |