Commit 838caf490a9b29736d9199d3b3931f208113e841
1 parent
1d5fb8d9
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
All tests fixed
Showing
2 changed files
with
5 additions
and
12 deletions
Show diff stats
lib/noosfero/api/session.rb
@@ -39,7 +39,9 @@ module Noosfero | @@ -39,7 +39,9 @@ module Noosfero | ||
39 | unique_attributes! User, [:email, :login] | 39 | unique_attributes! User, [:email, :login] |
40 | attrs = attributes_for_keys [:email, :login, :password, :password_confirmation] + environment.signup_person_fields | 40 | attrs = attributes_for_keys [:email, :login, :password, :password_confirmation] + environment.signup_person_fields |
41 | remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) | 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 | user = User.new(attrs) | 45 | user = User.new(attrs) |
44 | if user.save | 46 | if user.save |
45 | user.generate_private_token! if user.activated? | 47 | user.generate_private_token! if user.activated? |
@@ -124,10 +126,6 @@ module Noosfero | @@ -124,10 +126,6 @@ module Noosfero | ||
124 | end | 126 | end |
125 | end | 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 | end | 129 | end |
132 | end | 130 | end |
133 | end | 131 | end |
test/unit/api/session_test.rb
@@ -64,8 +64,8 @@ class SessionTest < ActiveSupport::TestCase | @@ -64,8 +64,8 @@ class SessionTest < ActiveSupport::TestCase | ||
64 | params = {:login => "newuserapi", :password => "newuserapi", :password_confirmation => "newuserapi", :email => "newuserapi@email.com", | 64 | params = {:login => "newuserapi", :password => "newuserapi", :password_confirmation => "newuserapi", :email => "newuserapi@email.com", |
65 | :txtToken_captcha_serpro_gov_br => '4324343', :captcha_text => '4030320'} | 65 | :txtToken_captcha_serpro_gov_br => '4324343', :captcha_text => '4030320'} |
66 | post "/api/v1/register?#{params.to_query}" | 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 | end | 69 | end |
70 | 70 | ||
71 | # TODO: Add another test cases to check register situations | 71 | # TODO: Add another test cases to check register situations |
@@ -161,9 +161,4 @@ class SessionTest < ActiveSupport::TestCase | @@ -161,9 +161,4 @@ class SessionTest < ActiveSupport::TestCase | ||
161 | assert_equal 404, last_response.status | 161 | assert_equal 404, last_response.status |
162 | end | 162 | end |
163 | 163 | ||
164 | - should 'show erro' do | ||
165 | - post "/api/v1/error" | ||
166 | - puts last_response.inspect | ||
167 | - end | ||
168 | - | ||
169 | end | 164 | end |