validates_captcha 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,71 +0,0 @@
1
- require 'test_helper'
2
-
3
- MW = ValidatesCaptcha::Middleware::Simple
4
-
5
- class MiddlewareTest < ValidatesCaptcha::TestCase
6
- test "defines an instance level #image_path method" do
7
- assert_respond_to MW.new, :image_path
8
- end
9
-
10
- test "instance level #image_path method accepts an argument" do
11
- assert_nothing_raised { MW.new.image_path('test') }
12
- end
13
-
14
- test "instance level #image_path method returns a string" do
15
- assert_kind_of String, MW.new.image_path('test')
16
- end
17
-
18
- test "defines an instance level #regenerate_path method" do
19
- assert_respond_to MW.new, :image_path
20
- end
21
-
22
- test "instance level #regenerate_path method returns a string" do
23
- assert_kind_of String, MW.new.regenerate_path
24
- end
25
-
26
- test "calling middleware with unrecognized path should have response status 404" do
27
- result = MW.new.call 'PATH_INFO' => '/unrecognized'
28
-
29
- assert_equal 404, result.first
30
- end
31
-
32
- test "calling middleware with recognized path should not have response status 404" do
33
- result = MW.new.call 'PATH_INFO' => ValidatesCaptcha.captcha_image_path('abc123')
34
-
35
- assert_not_equal 404, result.first
36
- end
37
-
38
- test "calling middleware with valid encrypted captcha code should have response status 200" do
39
- encrypted_code = ValidatesCaptcha.encrypt_captcha_code('hello')
40
- result = MW.new.call 'PATH_INFO' => "/captchas/#{encrypted_code}"
41
-
42
- assert_equal 200, result.first
43
- end
44
-
45
- test "calling middleware with valid encrypted captcha code should have expected content type response header" do
46
- encrypted_code = ValidatesCaptcha.encrypt_captcha_code('hello')
47
- result = MW.new.call 'PATH_INFO' => "/captchas/#{encrypted_code}"
48
-
49
- assert result.second.key?('Content-Type')
50
- assert_equal ValidatesCaptcha.captcha_image_mime_type, result.second['Content-Type']
51
- end
52
-
53
- test "calling middleware with invalid encrypted captcha code should have response status 422" do
54
- result = MW.new.call 'PATH_INFO' => "/captchas/invalid123"
55
-
56
- assert_equal 422, result.first
57
- end
58
-
59
- test "calling middleware with regenerate path should have response status 200" do
60
- result = MW.new.call 'PATH_INFO' => ValidatesCaptcha.regenerate_captcha_path
61
-
62
- assert_equal 200, result.first
63
- end
64
-
65
- test "calling middleware with regenerate path should have content type response header set to application/json" do
66
- result = MW.new.call 'PATH_INFO' => ValidatesCaptcha.regenerate_captcha_path
67
-
68
- assert result.second.key?('Content-Type')
69
- assert_equal 'application/json', result.second['Content-Type']
70
- end
71
- end