Commit 838caf490a9b29736d9199d3b3931f208113e841

Authored by Evandro Junior
1 parent 1d5fb8d9

All tests fixed

lib/noosfero/api/session.rb
... ... @@ -39,7 +39,9 @@ module Noosfero
39 39 unique_attributes! User, [:email, :login]
40 40 attrs = attributes_for_keys [:email, :login, :password, :password_confirmation] + environment.signup_person_fields
41 41 remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR'])
42   - test_captcha(remote_ip, params, environment)
  42 + # test_captcha will render_api_error! and exit in case of some problem
  43 + # this return is only improve the clarity of the execution path
  44 + return unless test_captcha(remote_ip, params, environment)
43 45 user = User.new(attrs)
44 46 if user.save
45 47 user.generate_private_token! if user.activated?
... ... @@ -124,10 +126,6 @@ module Noosfero
124 126 end
125 127 end
126 128  
127   - get "/stop" do
128   - stop!("show on screen", 400, "this is the log message", "go to JS")
129   - end
130   -
131 129 end
132 130 end
133 131 end
... ...
test/unit/api/session_test.rb
... ... @@ -64,8 +64,8 @@ class SessionTest < ActiveSupport::TestCase
64 64 params = {:login => "newuserapi", :password => "newuserapi", :password_confirmation => "newuserapi", :email => "newuserapi@email.com",
65 65 :txtToken_captcha_serpro_gov_br => '4324343', :captcha_text => '4030320'}
66 66 post "/api/v1/register?#{params.to_query}"
67   - message = JSON.parse(last_response.body)['message']
68   - assert_equal "Serpro captcha error: getaddrinfo: Name or service not known", JSON.parse(message)['javascript_console_message']
  67 + message = JSON.parse(last_response.body)['javascript_console_message']
  68 + assert_equal "Serpro captcha error: getaddrinfo: Name or service not known", message
69 69 end
70 70  
71 71 # TODO: Add another test cases to check register situations
... ... @@ -161,9 +161,4 @@ class SessionTest < ActiveSupport::TestCase
161 161 assert_equal 404, last_response.status
162 162 end
163 163  
164   - should 'show erro' do
165   - post "/api/v1/error"
166   - puts last_response.inspect
167   - end
168   -
169 164 end
... ...