Commit c9998be9ebadbb1838eb133b150990c87eeca008
1 parent
f0c82e2f
Exists in
staging
and in
3 other branches
All tests from login_captcha test are passing finally!
Showing
2 changed files
with
12 additions
and
8 deletions
Show diff stats
test/unit/api/login_captcha_test.rb
| ... | ... | @@ -3,14 +3,10 @@ require File.dirname(__FILE__) + '/test_helper' |
| 3 | 3 | class LoginCaptchaTest < ActiveSupport::TestCase |
| 4 | 4 | |
| 5 | 5 | def setup() |
| 6 | + @url = "/api/v1/login-captcha" | |
| 6 | 7 | OutcomeCaptcha.outcome_captcha_test = true |
| 7 | 8 | end |
| 8 | 9 | |
| 9 | - def create_article(name) | |
| 10 | - person = fast_create(Person, :environment_id => @environment.id) | |
| 11 | - fast_create(Article, :profile_id => person.id, :name => name) | |
| 12 | - end | |
| 13 | - | |
| 14 | 10 | should 'not perform a vote without authentication' do |
| 15 | 11 | article = create_article('Article 1') |
| 16 | 12 | params = {} |
| ... | ... | @@ -26,7 +22,6 @@ class LoginCaptchaTest < ActiveSupport::TestCase |
| 26 | 22 | assert_not_nil @private_token |
| 27 | 23 | end |
| 28 | 24 | |
| 29 | - | |
| 30 | 25 | should 'perform a vote in an article identified by id' do |
| 31 | 26 | login_with_captcha |
| 32 | 27 | article = create_article('Article 1') |
| ... | ... | @@ -69,9 +64,11 @@ class LoginCaptchaTest < ActiveSupport::TestCase |
| 69 | 64 | end |
| 70 | 65 | |
| 71 | 66 | should 'not generate private token when login without captcha' do |
| 67 | + OutcomeCaptcha.outcome_captcha_test = false | |
| 72 | 68 | params = {} |
| 73 | 69 | post "#{@url}#{params.to_query}" |
| 74 | 70 | json = JSON.parse(last_response.body) |
| 71 | + assert_equal last_response.status, 403 | |
| 75 | 72 | assert json["private_token"].blank? |
| 76 | 73 | end |
| 77 | 74 | ... | ... |
test/unit/api/test_helper.rb
| ... | ... | @@ -36,8 +36,15 @@ class ActiveSupport::TestCase |
| 36 | 36 | end |
| 37 | 37 | |
| 38 | 38 | def do_login_captcha_from_api |
| 39 | - #JSON.parse("") | |
| 40 | - "sasadasdaasdasdadadsadassadas" | |
| 39 | + post "/api/v1/login-captcha" | |
| 40 | + json = JSON.parse(last_response.body) | |
| 41 | + json | |
| 42 | + end | |
| 43 | + | |
| 44 | + def create_article(name) | |
| 45 | + @environment = Environment.default | |
| 46 | + person = fast_create(Person, :environment_id => @environment.id) | |
| 47 | + fast_create(Article, :profile_id => person.id, :name => name) | |
| 41 | 48 | end |
| 42 | 49 | |
| 43 | 50 | def login_api | ... | ... |