rambulance 1.1.0 → 1.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17bc50582db6ee389d7b677e43fcea58bdc91c758fdc953b39fa2fae52d7ae6c
4
- data.tar.gz: 1fdd148f730d07b03ce03f4722dd2c151d4291de58f515ed2084a347f66854d6
3
+ metadata.gz: 82265aa18e23300634878ce073d6b72effb62a3a8326832f603d9b17b7640634
4
+ data.tar.gz: 67abe21526c25ab05b2faada53dbadafd62bf414638752cdec3450256e326e3a
5
5
  SHA512:
6
- metadata.gz: 4238686586fb7e22c95230a00d6e7fabf28312f43b018d750a0008590205a40b64413777f6a43559d26c045501f4e82cb7ef814204cb07ea9432a5f06f9c9606
7
- data.tar.gz: a36d6333ec57c8706b3b5fb304362d0d1f1288b684009ee28842299bfb4daa015be58f93206eb146344d163d9e896166ce4dd4dc611af6d2e683124b742d30ab
6
+ metadata.gz: 97932a0989390b458d8b697cb3be797f0441b623898a34d03e1920ff50f1d298b6ec5c03650b63adf6191a18ed22e66efda0c71686022691e48dab3cd5bcc836
7
+ data.tar.gz: 2af8602230f377774c17cb1f2ce0e1861a28880f7e5682807d135772fb51d9f69c8613f772866b082efccdfc8e5158971acfeedce16bbfb95c24afc812d77053
@@ -1,3 +1,19 @@
1
+ ## v1.1.1 (unreleased)
2
+
3
+ - Fixes a bug where a malformed `Content-Type` header could break the exceptions app (#55, @gingerlime)
4
+
5
+ ## [v1.1.0](https://github.com/yuki24/rambulance/tree/v1.1.0)
6
+
7
+ _<sup>released at 2020-05-23 02:52:27 UTC</sup>_
8
+
9
+ #### Features
10
+
11
+ - Add support for Ruby 2.7 ([<tt>718531c</tt>](https://github.com/yuki24/rambulance/commit/718531c45b61d01dce91f401fd81dd6aefdefb31))
12
+
13
+ #### Bug fixes
14
+
15
+ - Fixes a bug where malformed MIME type in HTTP headers could break the exceptions app ([#53](https://github.com/yuki24/rambulance/issues/53), [#54](https://github.com/yuki24/rambulance/pull/54), [@gingerlime](https://github.com/gingerlime))
16
+
1
17
  ## [v1.0.3](https://github.com/yuki24/rambulance/tree/v1.0.3)
2
18
 
3
19
  _<sup>released at 2019-10-03 03:39:17 UTC</sup>_
@@ -55,6 +55,12 @@ module Rambulance
55
55
  private
56
56
 
57
57
  def process_action(*)
58
+ begin
59
+ request.content_mime_type
60
+ rescue Mime::Type::InvalidMimeType
61
+ request.env["MALFORMED_CONTENT_TYPE"], request.env["CONTENT_TYPE"] = request.env["CONTENT_TYPE"], "text/plain"
62
+ end
63
+
58
64
  begin
59
65
  request.GET
60
66
  rescue ActionController::BadRequest
@@ -1,3 +1,3 @@
1
1
  module Rambulance
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -55,6 +55,25 @@ class ErrorJsonTest < ActionDispatch::IntegrationTest
55
55
  end
56
56
  end
57
57
 
58
+ test 'returns an appropriate status based on the rails version when the HTTP Content-type header is malformed' do
59
+ if Rails::VERSION::STRING >= '5.1.0'
60
+ post '/users', headers: { "CONTENT_TYPE" => "charset=gbk" }
61
+ else
62
+ post '/users', nil, "CONTENT_TYPE" => "charset=gbk"
63
+ end
64
+
65
+ if Rails::VERSION::STRING >= '6.0.0'
66
+ assert_equal 406, response.status
67
+ assert_equal "The requested content type is not acceptable.\n", response.body
68
+ elsif Rails::VERSION::STRING >= '5.2.0'
69
+ assert_equal 422, response.status
70
+ elsif Rails::VERSION::STRING >= '5.1.0'
71
+ assert_equal 500, response.status
72
+ elsif Rails::VERSION::STRING >= '4.2.0'
73
+ assert_equal 201, response.status
74
+ end
75
+ end
76
+
58
77
  private
59
78
 
60
79
  def without_layouts
@@ -67,12 +86,12 @@ class ErrorJsonTest < ActionDispatch::IntegrationTest
67
86
  `mv error.html.erb test/fake_app/app/views/layouts/`
68
87
  end
69
88
 
70
- def get(path)
89
+ def get(path, params: {}, headers: {})
71
90
  without_layouts do
72
91
  if Rails::VERSION::STRING >= '5.1.0'
73
- super path, headers: { "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json" }
92
+ super path, params: params, headers: { "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json" }.merge(headers)
74
93
  else
75
- super path, nil, "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"
94
+ super path, params, { "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json" }.merge(headers)
76
95
  end
77
96
  end
78
97
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rambulance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Nishijima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-23 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport