[Git][noosfero/noosfero][master] api: fix endpoint that destroy profiles
Victor Costa
gitlab at mg.gitlab.com
Fri Mar 31 08:18:23 BRT 2017
Victor Costa pushed to branch master at Noosfero / noosfero
Commits:
03cf8bac by Victor Costa at 2017-03-31T08:17:27-03:00
api: fix endpoint that destroy profiles
- - - - -
2 changed files:
- app/api/v1/profiles.rb
- test/api/profiles_test.rb
Changes:
=====================================
app/api/v1/profiles.rb
=====================================
--- a/app/api/v1/profiles.rb
+++ b/app/api/v1/profiles.rb
@@ -53,7 +53,7 @@ module Api
not_found! if profile.blank?
if profile.allow_destroy?(current_person)
- profile.destroy
+ present({ success: profile.destroy })
else
forbidden!
end
=====================================
test/api/profiles_test.rb
=====================================
--- a/test/api/profiles_test.rb
+++ b/test/api/profiles_test.rb
@@ -69,8 +69,10 @@ class ProfilesTest < ActiveSupport::TestCase
should 'person delete itself' do
login_api
delete "/api/v1/profiles/#{@person.id}?#{params.to_query}"
+ json = JSON.parse(last_response.body)
assert_includes [200, 204], last_response.status
assert_nil Profile.find_by_id @person.id
+ assert json['success']
end
should 'only admin delete other people' do
View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/03cf8bac6447dafbab90f31ebaa3b110a5ab9c35
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170331/395677b7/attachment-0001.html>
More information about the Noosfero-dev
mailing list