Commit 8c6a28dd5beff52cec5f41eac0c1db2aef5d4992

Authored by Carlos Purificação
2 parents e383f819 ade200e4

Merge remote-tracking branch 'origin/production' into translate

lib/noosfero/api/helpers.rb
... ... @@ -273,7 +273,7 @@ require 'grape'
273 273 if javascript_console_message.present?
274 274 error!(message_hash, status)
275 275 else
276   - error!(user_message, status)
  276 + error!({'message' => user_message, :code => status}, status)
277 277 end
278 278 end
279 279  
... ...
lib/noosfero/api/session.rb
... ... @@ -38,8 +38,8 @@ module Noosfero
38 38 post "/register" do
39 39 attrs = attributes_for_keys [:email, :login, :password, :password_confirmation] + environment.signup_person_fields
40 40 remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR'])
41   - # test_captcha will render_api_error! and exit in case of some problem
42   - # this return is only improve the clarity of the execution path
  41 + # test_captcha will render_api_error! and exit in case of any problem
  42 + # this return is just to improve the clarity of the execution path
43 43 return unless test_captcha(remote_ip, params, environment)
44 44 user = User.new(attrs)
45 45 if user.save
... ... @@ -96,7 +96,10 @@ module Noosfero
96 96 post "/forgot_password" do
97 97 requestors = fetch_requestors(params[:value])
98 98 not_found! if requestors.blank?
99   -
  99 + remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR'])
  100 + # test_captcha will render_api_error! and exit in case of any problem
  101 + # this return is just to improve the clarity of the execution path
  102 + return unless test_captcha(remote_ip, params, environment)
100 103 requestors.each do |requestor|
101 104 ChangePassword.create!(:requestor => requestor)
102 105 end
... ...
test/unit/api/users_test.rb
... ... @@ -29,7 +29,7 @@ class UsersTest < ActiveSupport::TestCase
29 29 params[:user] = {:login => 'some', :password => '123456', :password_confirmation => '123456', :email => 'some@some.com'}
30 30 post "/api/v1/users?#{params.to_query}"
31 31 json = JSON.parse(last_response.body)
32   - assert_equal 'Username / Email já está em uso,e-Mail já está em uso', json['error']
  32 + assert_equal 'Username / Email já está em uso,e-Mail já está em uso', json['message']
33 33 end
34 34  
35 35 should 'return 400 status for invalid user creation' do
... ...