[Git][noosfero/noosfero][master] 2 commits: api: pass current_person in boxes endpoint
Victor Costa
gitlab at mg.gitlab.com
Wed May 18 19:32:54 BRT 2016
Victor Costa pushed to branch master at Noosfero / noosfero
Commits:
b416e69d by Victor Costa at 2016-05-18T19:10:29-03:00
api: pass current_person in boxes endpoint
- - - - -
b896adbe by Victor Costa at 2016-05-18T22:32:41+00:00
Merge branch 'fix-boxes-api' into 'master'
api: pass current_person in boxes endpoint
See merge request !929
- - - - -
2 changed files:
- app/api/v1/boxes.rb
- test/api/boxes_test.rb
Changes:
=====================================
app/api/v1/boxes.rb
=====================================
--- a/app/api/v1/boxes.rb
+++ b/app/api/v1/boxes.rb
@@ -13,7 +13,7 @@ module Api
get do
profile = environment.send(kind.pluralize).find(params["#{kind}_id"])
return forbidden! unless profile.display_info_to?(current_person)
- present profile.boxes, :with => Entities::Box
+ present profile.boxes, with: Entities::Box, current_person: current_person
end
end
end
@@ -33,7 +33,7 @@ module Api
else
env = Environment.find(params[:environment_id])
end
- present env.boxes, :with => Entities::Box
+ present env.boxes, with: Entities::Box, current_person: current_person
end
end
end
=====================================
test/api/boxes_test.rb
=====================================
--- a/test/api/boxes_test.rb
+++ b/test/api/boxes_test.rb
@@ -70,6 +70,17 @@ class BoxesTest < ActiveSupport::TestCase
assert_equal [], json["boxes"].first["blocks"].map {|b| b['id']}
end
+ should 'list a block with logged in display_user for a logged user' do
+ profile = fast_create(Profile)
+ box = fast_create(Box, :owner_id => profile.id, :owner_type => Profile.name)
+ block = fast_create(Block, box_id: box.id)
+ block.display_user = 'logged'
+ block.save!
+ get "/api/v1/profiles/#{profile.id}/boxes?#{params.to_query}"
+ json = JSON.parse(last_response.body)
+ assert_equal [block.id], json["boxes"].first["blocks"].map {|b| b['id']}
+ end
+
should 'not list boxes for user without permission' do
profile = fast_create(Profile, public_profile: false)
box = fast_create(Box, :owner_id => profile.id, :owner_type => Profile.name)
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/69041ef55b6df9bba11c4b025e08e4bb70dc5af3...b896adbeac95cf3589223ad463c31d17d4bb5b17
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160518/3d7b6c80/attachment-0001.html>
More information about the Noosfero-dev
mailing list