diff --git a/test/unit/api/login_captcha_test.rb b/test/unit/api/login_captcha_test.rb index cee1f59..67e9ca3 100644 --- a/test/unit/api/login_captcha_test.rb +++ b/test/unit/api/login_captcha_test.rb @@ -3,14 +3,10 @@ require File.dirname(__FILE__) + '/test_helper' class LoginCaptchaTest < ActiveSupport::TestCase def setup() + @url = "/api/v1/login-captcha" OutcomeCaptcha.outcome_captcha_test = true end - def create_article(name) - person = fast_create(Person, :environment_id => @environment.id) - fast_create(Article, :profile_id => person.id, :name => name) - end - should 'not perform a vote without authentication' do article = create_article('Article 1') params = {} @@ -26,7 +22,6 @@ class LoginCaptchaTest < ActiveSupport::TestCase assert_not_nil @private_token end - should 'perform a vote in an article identified by id' do login_with_captcha article = create_article('Article 1') @@ -69,9 +64,11 @@ class LoginCaptchaTest < ActiveSupport::TestCase end should 'not generate private token when login without captcha' do + OutcomeCaptcha.outcome_captcha_test = false params = {} post "#{@url}#{params.to_query}" json = JSON.parse(last_response.body) + assert_equal last_response.status, 403 assert json["private_token"].blank? end diff --git a/test/unit/api/test_helper.rb b/test/unit/api/test_helper.rb index a72f0af..40d2a47 100644 --- a/test/unit/api/test_helper.rb +++ b/test/unit/api/test_helper.rb @@ -36,8 +36,15 @@ class ActiveSupport::TestCase end def do_login_captcha_from_api - #JSON.parse("") - "sasadasdaasdasdadadsadassadas" + post "/api/v1/login-captcha" + json = JSON.parse(last_response.body) + json + end + + def create_article(name) + @environment = Environment.default + person = fast_create(Person, :environment_id => @environment.id) + fast_create(Article, :profile_id => person.id, :name => name) end def login_api -- libgit2 0.21.2