rambulance 1.0.3 → 2.2.0
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 +4 -4
- data/.github/workflows/tests.yml +123 -0
- data/Appraisals +15 -26
- data/CHANGELOG.md +52 -1
- data/README.md +5 -5
- data/gemfiles/rails_60.gemfile +3 -3
- data/gemfiles/rails_61.gemfile +9 -0
- data/gemfiles/rails_70.gemfile +9 -0
- data/lib/generators/rambulance/templates/rambulance.rb +1 -1
- data/lib/rambulance/exceptions_app.rb +23 -1
- data/lib/rambulance/version.rb +1 -1
- data/lib/rambulance.rb +1 -1
- data/rambulance.gemspec +1 -1
- data/test/fake_app/rails_app.rb +3 -0
- data/test/requests/error_json_test.rb +56 -3
- metadata +10 -10
- data/.travis.yml +0 -51
- data/gemfiles/rails_32.gemfile +0 -11
- data/gemfiles/rails_40.gemfile +0 -11
- data/gemfiles/rails_41.gemfile +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6096e0f9c5586790a9b288cb471a849674b1dfa4cefd2786b919f7bb61643961
|
|
4
|
+
data.tar.gz: 8d11d4e7517e9ea7e8f8326de68408c76b60c8b1cae173dddb0891ff267b2f0d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0fbecc629b39ef1e50124b4e75be719c107a504c48de722e870bc471d8529b44c3c869442c83f373de50a096ddcd154d9861fae579ec49e6251f4cd38161befb
|
|
7
|
+
data.tar.gz: f6e08a20ba72aefea6aee3f8fc258463a86827df03590309724d2af3f2bae4a355c615d860e19c446e913cff02f7dd4ba84f3132d594f9a9f6e89a7e8d04b654
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
name: build
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
- push
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
stable:
|
|
8
|
+
strategy:
|
|
9
|
+
matrix:
|
|
10
|
+
ruby_version:
|
|
11
|
+
- '3.1'
|
|
12
|
+
- '3.0'
|
|
13
|
+
- '2.7'
|
|
14
|
+
- '2.6'
|
|
15
|
+
- '2.5'
|
|
16
|
+
- '2.4'
|
|
17
|
+
- '2.3'
|
|
18
|
+
- 'jruby-9.3.3.0'
|
|
19
|
+
gemfile:
|
|
20
|
+
- gemfiles/rails_70.gemfile
|
|
21
|
+
- gemfiles/rails_61.gemfile
|
|
22
|
+
- gemfiles/rails_60.gemfile
|
|
23
|
+
- gemfiles/rails_52.gemfile
|
|
24
|
+
- gemfiles/rails_51.gemfile
|
|
25
|
+
- gemfiles/rails_50.gemfile
|
|
26
|
+
- gemfiles/rails_42.gemfile
|
|
27
|
+
exclude:
|
|
28
|
+
- ruby_version: '3.1'
|
|
29
|
+
gemfile: gemfiles/rails_60.gemfile
|
|
30
|
+
- ruby_version: '3.1'
|
|
31
|
+
gemfile: gemfiles/rails_52.gemfile
|
|
32
|
+
- ruby_version: '3.1'
|
|
33
|
+
gemfile: gemfiles/rails_51.gemfile
|
|
34
|
+
- ruby_version: '3.1'
|
|
35
|
+
gemfile: gemfiles/rails_50.gemfile
|
|
36
|
+
- ruby_version: '3.1'
|
|
37
|
+
gemfile: gemfiles/rails_42.gemfile
|
|
38
|
+
- ruby_version: '3.0'
|
|
39
|
+
gemfile: gemfiles/rails_52.gemfile
|
|
40
|
+
- ruby_version: '3.0'
|
|
41
|
+
gemfile: gemfiles/rails_51.gemfile
|
|
42
|
+
- ruby_version: '3.0'
|
|
43
|
+
gemfile: gemfiles/rails_50.gemfile
|
|
44
|
+
- ruby_version: '3.0'
|
|
45
|
+
gemfile: gemfiles/rails_42.gemfile
|
|
46
|
+
- ruby_version: '2.7'
|
|
47
|
+
gemfile: gemfiles/rails_70.gemfile
|
|
48
|
+
- ruby_version: '2.7'
|
|
49
|
+
gemfile: gemfiles/rails_52.gemfile
|
|
50
|
+
- ruby_version: '2.7'
|
|
51
|
+
gemfile: gemfiles/rails_51.gemfile
|
|
52
|
+
- ruby_version: '2.7'
|
|
53
|
+
gemfile: gemfiles/rails_50.gemfile
|
|
54
|
+
- ruby_version: '2.7'
|
|
55
|
+
gemfile: gemfiles/rails_42.gemfile
|
|
56
|
+
- ruby_version: '2.6'
|
|
57
|
+
gemfile: gemfiles/rails_70.gemfile
|
|
58
|
+
- ruby_version: '2.6'
|
|
59
|
+
gemfile: gemfiles/rails_42.gemfile
|
|
60
|
+
- ruby_version: '2.5'
|
|
61
|
+
gemfile: gemfiles/rails_70.gemfile
|
|
62
|
+
- ruby_version: '2.4'
|
|
63
|
+
gemfile: gemfiles/rails_70.gemfile
|
|
64
|
+
- ruby_version: '2.4'
|
|
65
|
+
gemfile: gemfiles/rails_61.gemfile
|
|
66
|
+
- ruby_version: '2.4'
|
|
67
|
+
gemfile: gemfiles/rails_60.gemfile
|
|
68
|
+
- ruby_version: '2.3'
|
|
69
|
+
gemfile: gemfiles/rails_70.gemfile
|
|
70
|
+
- ruby_version: '2.3'
|
|
71
|
+
gemfile: gemfiles/rails_61.gemfile
|
|
72
|
+
- ruby_version: '2.3'
|
|
73
|
+
gemfile: gemfiles/rails_60.gemfile
|
|
74
|
+
- ruby_version: 'jruby-9.3.3.0'
|
|
75
|
+
gemfile: gemfiles/rails_70.gemfile
|
|
76
|
+
- ruby_version: 'jruby-9.3.3.0'
|
|
77
|
+
gemfile: gemfiles/rails_51.gemfile
|
|
78
|
+
- ruby_version: 'jruby-9.3.3.0'
|
|
79
|
+
gemfile: gemfiles/rails_50.gemfile
|
|
80
|
+
- ruby_version: 'jruby-9.3.3.0'
|
|
81
|
+
gemfile: gemfiles/rails_42.gemfile
|
|
82
|
+
runs-on: ubuntu-18.04
|
|
83
|
+
env:
|
|
84
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
85
|
+
steps:
|
|
86
|
+
- uses: actions/checkout@v2
|
|
87
|
+
- name: Set up Ruby
|
|
88
|
+
uses: ruby/setup-ruby@v1
|
|
89
|
+
with:
|
|
90
|
+
ruby-version: ${{ matrix.ruby_version }}
|
|
91
|
+
bundler-cache: true
|
|
92
|
+
- run: bundle exec rake
|
|
93
|
+
|
|
94
|
+
rails_edge:
|
|
95
|
+
runs-on: ubuntu-18.04
|
|
96
|
+
env:
|
|
97
|
+
BUNDLE_GEMFILE: gemfiles/rails_edge.gemfile
|
|
98
|
+
steps:
|
|
99
|
+
- uses: actions/checkout@v2
|
|
100
|
+
- name: Set up Ruby
|
|
101
|
+
uses: ruby/setup-ruby@v1
|
|
102
|
+
with:
|
|
103
|
+
ruby-version: 3.1
|
|
104
|
+
bundler-cache: true
|
|
105
|
+
- run: bundle exec rake
|
|
106
|
+
|
|
107
|
+
ruby_edge:
|
|
108
|
+
strategy:
|
|
109
|
+
matrix:
|
|
110
|
+
gemfile:
|
|
111
|
+
- gemfiles/rails_edge.gemfile
|
|
112
|
+
- gemfiles/rails_70.gemfile
|
|
113
|
+
runs-on: ubuntu-18.04
|
|
114
|
+
env:
|
|
115
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
116
|
+
steps:
|
|
117
|
+
- uses: actions/checkout@v2
|
|
118
|
+
- name: Set up Ruby
|
|
119
|
+
uses: ruby/setup-ruby@v1
|
|
120
|
+
with:
|
|
121
|
+
ruby-version: 'ruby-head'
|
|
122
|
+
bundler-cache: true
|
|
123
|
+
- run: bundle exec rake || echo "Ruby edge test is done."
|
data/Appraisals
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
appraise "rails_32" do
|
|
2
|
-
gem "activesupport", "~> 3.2.0"
|
|
3
|
-
gem "actionpack", "~> 3.2.0"
|
|
4
|
-
gem "railties", "~> 3.2.0"
|
|
5
|
-
gem "test-unit" if RUBY_VERSION >= "2.2.0"
|
|
6
|
-
gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
appraise "rails_40" do
|
|
10
|
-
gem "activesupport", "~> 4.0.0"
|
|
11
|
-
gem "actionpack", "~> 4.0.0"
|
|
12
|
-
gem "railties", "~> 4.0.0"
|
|
13
|
-
gem "test-unit" if RUBY_VERSION >= "2.2.0"
|
|
14
|
-
gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
appraise "rails_41" do
|
|
18
|
-
gem "activesupport", "~> 4.1.0"
|
|
19
|
-
gem "actionpack", "~> 4.1.0"
|
|
20
|
-
gem "railties", "~> 4.1.0"
|
|
21
|
-
gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
1
|
appraise "rails_42" do
|
|
25
2
|
gem "activesupport", "~> 4.2.0"
|
|
26
3
|
gem "actionpack", "~> 4.2.0"
|
|
@@ -49,9 +26,21 @@ appraise "rails_52" do
|
|
|
49
26
|
end
|
|
50
27
|
|
|
51
28
|
appraise "rails_60" do
|
|
52
|
-
gem "activesupport", "~> 6.0.0
|
|
53
|
-
gem "actionpack", "~> 6.0.0
|
|
54
|
-
gem "railties", "~> 6.0.0
|
|
29
|
+
gem "activesupport", "~> 6.0.0"
|
|
30
|
+
gem "actionpack", "~> 6.0.0"
|
|
31
|
+
gem "railties", "~> 6.0.0"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
appraise "rails_61" do
|
|
35
|
+
gem "activesupport", "~> 6.1.0"
|
|
36
|
+
gem "actionpack", "~> 6.1.0"
|
|
37
|
+
gem "railties", "~> 6.1.0"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
appraise "rails_70" do
|
|
41
|
+
gem "activesupport", "~> 7.0.0"
|
|
42
|
+
gem "actionpack", "~> 7.0.0"
|
|
43
|
+
gem "railties", "~> 7.0.0"
|
|
55
44
|
end
|
|
56
45
|
|
|
57
46
|
appraise "rails_edge" do
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
+
## v2.1.0
|
|
2
|
+
|
|
3
|
+
_<sup>released at 2022-02-22 07:52:27 UTC</sup>_
|
|
4
|
+
|
|
5
|
+
- Add support for Ruby 3.1, Rails 7.0 and JRuby 9.3.3.0
|
|
6
|
+
|
|
7
|
+
## [v2.0.0](https://github.com/yuki24/rambulance/tree/v2.0.0)
|
|
8
|
+
|
|
9
|
+
_<sup>released at 2021-09-22 02:49:18 UTC</sup>_
|
|
10
|
+
|
|
11
|
+
#### Breaking Changes
|
|
12
|
+
|
|
13
|
+
- Drop support for Rails 4.1 and older ([#62](https://github.com/yuki24/rambulance/pull/62), [@yuki24](https://github.com/yuki24))
|
|
14
|
+
|
|
15
|
+
#### Features
|
|
16
|
+
|
|
17
|
+
- Add support for Rails 6.1 and Ruby 3.0 ([#61](https://github.com/yuki24/rambulance/pull/61), [#63](https://github.com/yuki24/rambulance/pull/63), [@gingerlime](https://github.com/gingerlime), [@yuki24](https://github.com/yuki24))
|
|
18
|
+
|
|
19
|
+
#### Bug fixes
|
|
20
|
+
|
|
21
|
+
- POST with invalid JSON triggers a 500 ([#59](https://github.com/yuki24/rambulance/pull/59), [@gingerlime](https://github.com/gingerlime))
|
|
22
|
+
- Fix 'directry' typo ([#57](https://github.com/yuki24/rambulance/pull/57), [@andyw8](https://github.com/andyw8))
|
|
23
|
+
|
|
24
|
+
## [v1.1.1](https://github.com/yuki24/rambulance/tree/v1.1.1)
|
|
25
|
+
|
|
26
|
+
_<sup>released at 2020-05-28 23:22:10 UTC</sup>_
|
|
27
|
+
|
|
28
|
+
#### Bug fixes
|
|
29
|
+
|
|
30
|
+
- Fixes a bug where a malformed `Content-Type` header could break the exceptions app ([#55](https://github.com/yuki24/rambulance/pull/55), [@gingerlime](https://github.com/gingerlime))
|
|
31
|
+
|
|
32
|
+
## [v1.1.0](https://github.com/yuki24/rambulance/tree/v1.1.0)
|
|
33
|
+
|
|
34
|
+
_<sup>released at 2020-05-23 02:52:27 UTC</sup>_
|
|
35
|
+
|
|
36
|
+
#### Features
|
|
37
|
+
|
|
38
|
+
- Add support for Ruby 2.7 ([<tt>718531c</tt>](https://github.com/yuki24/rambulance/commit/718531c45b61d01dce91f401fd81dd6aefdefb31))
|
|
39
|
+
|
|
40
|
+
#### Bug fixes
|
|
41
|
+
|
|
42
|
+
- 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))
|
|
43
|
+
|
|
44
|
+
## [v1.0.3](https://github.com/yuki24/rambulance/tree/v1.0.3)
|
|
45
|
+
|
|
46
|
+
_<sup>released at 2019-10-03 03:39:17 UTC</sup>_
|
|
47
|
+
|
|
48
|
+
#### Fixes
|
|
49
|
+
|
|
50
|
+
- Fixes a bug where custom exceptions app can not be loaded properly on Rails 6 and Zeitwerk ([#52](https://github.com/yuki24/rambulance/issues/52), [@sho918](https://github.com/sho918))
|
|
51
|
+
|
|
1
52
|
## [v1.0.2](https://github.com/yuki24/rambulance/tree/v1.0.2)
|
|
2
53
|
|
|
3
54
|
_<sup>released at 2019-06-06 23:39:38 UTC</sup>_
|
|
@@ -58,7 +109,7 @@ _<sup>released at 2018-01-02 21:36:02 UTC</sup>_
|
|
|
58
109
|
#### Breaking changes & deprecations
|
|
59
110
|
|
|
60
111
|
- Drop support for Ruby 1.9.3
|
|
61
|
-
- Drop support for
|
|
112
|
+
- Drop support for Haml and Slim templates
|
|
62
113
|
|
|
63
114
|
#### Bug fixes
|
|
64
115
|
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Rambulance [](https://github.com/yuki24/rambulance/actions/workflows/tests.yml) [](https://rubygems.org/gems/rambulance)
|
|
2
2
|
|
|
3
3
|
A simple and safe way to dynamically render error pages for Rails apps.
|
|
4
4
|
|
|
@@ -69,7 +69,7 @@ This is useful when you want to edit templates without changing Rails configurat
|
|
|
69
69
|
|
|
70
70
|
Change `config.consider_all_requests_local` to _false_ in `config/environments/development.rb`.
|
|
71
71
|
|
|
72
|
-
```
|
|
72
|
+
```ruby
|
|
73
73
|
config.consider_all_requests_local = false
|
|
74
74
|
```
|
|
75
75
|
|
|
@@ -79,7 +79,7 @@ This simulates how your production app displays error pages so you can actually
|
|
|
79
79
|
|
|
80
80
|
If you want to do some more things in a exceptions app, you can also write your own custom exceptions app:
|
|
81
81
|
|
|
82
|
-
```
|
|
82
|
+
```sh
|
|
83
83
|
$ rails g rambulance:exceptions_app
|
|
84
84
|
```
|
|
85
85
|
|
|
@@ -123,8 +123,8 @@ Note that testing error pages is not encouraged in Rails as it leads to overuse
|
|
|
123
123
|
|
|
124
124
|
## Supported Versions
|
|
125
125
|
|
|
126
|
-
* Ruby 2.3, 2,4, 2,5, 2.6,
|
|
127
|
-
* Rails 4.2, 5.0, 5.1, 5.2, 6.0 and edge
|
|
126
|
+
* Ruby 2.3, 2,4, 2,5, 2.6, 2.7, 3.0, 3.1, and JRuby 9.3
|
|
127
|
+
* Rails 4.2, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0 and edge
|
|
128
128
|
|
|
129
129
|
Rambulance doesn't work with Rails 3.1 and below since they don't provide a way to use a custom exceptions app.
|
|
130
130
|
|
data/gemfiles/rails_60.gemfile
CHANGED
|
@@ -26,7 +26,7 @@ Rambulance.setup do |config|
|
|
|
26
26
|
# 'app/views/layout/error_page.html.erb' as a layout for all the error pages.
|
|
27
27
|
config.layout_name = "error"
|
|
28
28
|
|
|
29
|
-
# The
|
|
29
|
+
# The directory name to organize error page templates. The default value is
|
|
30
30
|
# 'errors'. For example, if this value is set to "error_pages", Rambulance
|
|
31
31
|
# uses e.g. 'app/views/error_pages/not_found.html.erb'.
|
|
32
32
|
config.view_path = "errors"
|
|
@@ -9,6 +9,16 @@ module Rambulance
|
|
|
9
9
|
http_status >= 400 && ![418, 427, 430, 509].include?(http_status)
|
|
10
10
|
end.invert
|
|
11
11
|
|
|
12
|
+
BAD_REQUEST_ERRORS = [
|
|
13
|
+
ActionController::BadRequest,
|
|
14
|
+
begin
|
|
15
|
+
ActionDispatch::Http::Parameters::ParseError # Rails >= 5.2.0
|
|
16
|
+
rescue NameError; end,
|
|
17
|
+
begin
|
|
18
|
+
ActionDispatch::ParamsParser::ParseError # Rails < 5.2.0
|
|
19
|
+
rescue NameError; end,
|
|
20
|
+
].compact.freeze
|
|
21
|
+
|
|
12
22
|
class ExceptionsApp < ActionController::Base
|
|
13
23
|
layout :layout_name
|
|
14
24
|
|
|
@@ -55,6 +65,12 @@ module Rambulance
|
|
|
55
65
|
private
|
|
56
66
|
|
|
57
67
|
def process_action(*)
|
|
68
|
+
begin
|
|
69
|
+
request.content_mime_type
|
|
70
|
+
rescue Mime::Type::InvalidMimeType
|
|
71
|
+
request.env["MALFORMED_CONTENT_TYPE"], request.env["CONTENT_TYPE"] = request.env["CONTENT_TYPE"], "text/plain"
|
|
72
|
+
end
|
|
73
|
+
|
|
58
74
|
begin
|
|
59
75
|
request.GET
|
|
60
76
|
rescue ActionController::BadRequest
|
|
@@ -63,10 +79,16 @@ module Rambulance
|
|
|
63
79
|
|
|
64
80
|
begin
|
|
65
81
|
request.POST
|
|
66
|
-
rescue
|
|
82
|
+
rescue *BAD_REQUEST_ERRORS
|
|
67
83
|
request.env["MALFORMED_BODY"], request.env["rack.input"] = request.env["rack.input"], StringIO.new
|
|
68
84
|
end
|
|
69
85
|
|
|
86
|
+
begin
|
|
87
|
+
request.accepts
|
|
88
|
+
rescue Mime::Type::InvalidMimeType
|
|
89
|
+
request.env["MALFORMED_HTTP_ACCEPT"], request.env["HTTP_ACCEPT"] = request.env["HTTP_ACCEPT"], "*/*"
|
|
90
|
+
end
|
|
91
|
+
|
|
70
92
|
# The #formats method needs to be called after the sanitization above.
|
|
71
93
|
request.formats << Mime::Type.lookup('text/plain')
|
|
72
94
|
|
data/lib/rambulance/version.rb
CHANGED
data/lib/rambulance.rb
CHANGED
data/rambulance.gemspec
CHANGED
|
@@ -6,7 +6,7 @@ require "rambulance/version"
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "rambulance"
|
|
8
8
|
spec.version = Rambulance::VERSION
|
|
9
|
-
spec.authors = ["Yuki Nishijima"]
|
|
9
|
+
spec.authors = ["Yuki Nishijima", "Yoav Aner"]
|
|
10
10
|
spec.email = ["mail@yukinishijima.net"]
|
|
11
11
|
spec.summary = %q{Simple and safe way to dynamically generate error pages}
|
|
12
12
|
spec.description = %q{Rambulance provides a simple and safe way to dynamically generate error pages.}
|
data/test/fake_app/rails_app.rb
CHANGED
|
@@ -8,6 +8,7 @@ class TestApp < Rails::Application
|
|
|
8
8
|
config.eager_load = false
|
|
9
9
|
config.root = File.dirname(__FILE__)
|
|
10
10
|
config.autoload_paths += ["#{config.root}/lib"] if ENV["CUSTOM_EXCEPTIONS_APP"]
|
|
11
|
+
config.hosts = "www.example.com"
|
|
11
12
|
|
|
12
13
|
if Rails::VERSION::STRING >= "5.2"
|
|
13
14
|
config.action_controller.default_protect_from_forgery = true
|
|
@@ -50,6 +51,7 @@ class ApplicationController < ActionController::Base
|
|
|
50
51
|
raise "This is a bad filter."
|
|
51
52
|
end
|
|
52
53
|
end
|
|
54
|
+
|
|
53
55
|
class UsersController < ApplicationController
|
|
54
56
|
if self.respond_to? :skip_before_action
|
|
55
57
|
skip_before_action :bad_filter, except: :show
|
|
@@ -79,6 +81,7 @@ class UsersController < ApplicationController
|
|
|
79
81
|
raise ForbiddenException
|
|
80
82
|
end
|
|
81
83
|
end
|
|
84
|
+
|
|
82
85
|
class ProjectsController < ApplicationController
|
|
83
86
|
if self.respond_to?(:skip_forgery_protection)
|
|
84
87
|
skip_forgery_protection
|
|
@@ -36,6 +36,59 @@ class ErrorJsonTest < ActionDispatch::IntegrationTest
|
|
|
36
36
|
assert_equal "Something went wrong", json_response['message']
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
test 'returns an appropriate status based on the rails version when the HTTP Accept header is malformed' do
|
|
40
|
+
if Rails::VERSION::STRING >= '5.1.0'
|
|
41
|
+
post '/users', headers: { "HTTP_ACCEPT" => "image/apng*/*" }
|
|
42
|
+
else
|
|
43
|
+
post '/users', nil, "HTTP_ACCEPT" => "image/apng*/*"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
if Rails::VERSION::STRING >= '6.0.0'
|
|
47
|
+
assert_equal 406, response.status
|
|
48
|
+
assert_equal "The requested content type is not acceptable.\n", response.body
|
|
49
|
+
elsif Rails::VERSION::STRING >= '5.2.0'
|
|
50
|
+
assert_equal 422, response.status
|
|
51
|
+
elsif Rails::VERSION::STRING >= '5.1.0'
|
|
52
|
+
assert_equal 500, response.status
|
|
53
|
+
elsif Rails::VERSION::STRING >= '4.2.0'
|
|
54
|
+
assert_equal 201, response.status
|
|
55
|
+
end
|
|
56
|
+
end
|
|
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
|
+
|
|
77
|
+
test 'returns an appropriate status when JSON data is malformed' do
|
|
78
|
+
if Rails::VERSION::STRING >= '5.1.0'
|
|
79
|
+
post '/unknown/path', params: 'x', headers: { "CONTENT_TYPE" => "application/json" }
|
|
80
|
+
else
|
|
81
|
+
post '/unknown/path', 'x', "CONTENT_TYPE" => "application/json"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
if Rails::VERSION::STRING >= '5.0.0'
|
|
85
|
+
assert_equal 404, response.status
|
|
86
|
+
elsif Rails::VERSION::STRING >= '4.2.0'
|
|
87
|
+
assert_equal 400, response.status
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
39
92
|
private
|
|
40
93
|
|
|
41
94
|
def without_layouts
|
|
@@ -48,12 +101,12 @@ class ErrorJsonTest < ActionDispatch::IntegrationTest
|
|
|
48
101
|
`mv error.html.erb test/fake_app/app/views/layouts/`
|
|
49
102
|
end
|
|
50
103
|
|
|
51
|
-
def get(path)
|
|
104
|
+
def get(path, params: {}, headers: {})
|
|
52
105
|
without_layouts do
|
|
53
106
|
if Rails::VERSION::STRING >= '5.1.0'
|
|
54
|
-
super path, headers: { "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json" }
|
|
107
|
+
super path, params: params, headers: { "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json" }.merge(headers)
|
|
55
108
|
else
|
|
56
|
-
super path,
|
|
109
|
+
super path, params, { "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json" }.merge(headers)
|
|
57
110
|
end
|
|
58
111
|
end
|
|
59
112
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rambulance
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yuki Nishijima
|
|
8
|
-
|
|
8
|
+
- Yoav Aner
|
|
9
|
+
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
+
date: 2022-02-13 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: activesupport
|
|
@@ -144,8 +145,8 @@ executables: []
|
|
|
144
145
|
extensions: []
|
|
145
146
|
extra_rdoc_files: []
|
|
146
147
|
files:
|
|
148
|
+
- ".github/workflows/tests.yml"
|
|
147
149
|
- ".gitignore"
|
|
148
|
-
- ".travis.yml"
|
|
149
150
|
- Appraisals
|
|
150
151
|
- CHANGELOG.md
|
|
151
152
|
- Dangerfile
|
|
@@ -155,14 +156,13 @@ files:
|
|
|
155
156
|
- Rakefile
|
|
156
157
|
- app/views/errors/internal_server_error.text.erb
|
|
157
158
|
- app/views/errors/not_acceptable.text.erb
|
|
158
|
-
- gemfiles/rails_32.gemfile
|
|
159
|
-
- gemfiles/rails_40.gemfile
|
|
160
|
-
- gemfiles/rails_41.gemfile
|
|
161
159
|
- gemfiles/rails_42.gemfile
|
|
162
160
|
- gemfiles/rails_50.gemfile
|
|
163
161
|
- gemfiles/rails_51.gemfile
|
|
164
162
|
- gemfiles/rails_52.gemfile
|
|
165
163
|
- gemfiles/rails_60.gemfile
|
|
164
|
+
- gemfiles/rails_61.gemfile
|
|
165
|
+
- gemfiles/rails_70.gemfile
|
|
166
166
|
- gemfiles/rails_edge.gemfile
|
|
167
167
|
- lib/generators/rambulance/exceptions_app_generator.rb
|
|
168
168
|
- lib/generators/rambulance/install_generator.rb
|
|
@@ -207,7 +207,7 @@ homepage: http://github.com/yuki24/rambulance
|
|
|
207
207
|
licenses:
|
|
208
208
|
- MIT
|
|
209
209
|
metadata: {}
|
|
210
|
-
post_install_message:
|
|
210
|
+
post_install_message:
|
|
211
211
|
rdoc_options: []
|
|
212
212
|
require_paths:
|
|
213
213
|
- lib
|
|
@@ -222,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
222
222
|
- !ruby/object:Gem::Version
|
|
223
223
|
version: '0'
|
|
224
224
|
requirements: []
|
|
225
|
-
rubygems_version: 3.
|
|
226
|
-
signing_key:
|
|
225
|
+
rubygems_version: 3.3.3
|
|
226
|
+
signing_key:
|
|
227
227
|
specification_version: 4
|
|
228
228
|
summary: Simple and safe way to dynamically generate error pages
|
|
229
229
|
test_files:
|
data/.travis.yml
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
cache: bundler
|
|
3
|
-
sudo: false
|
|
4
|
-
|
|
5
|
-
script:
|
|
6
|
-
- bundle exec rake
|
|
7
|
-
|
|
8
|
-
before_install:
|
|
9
|
-
- gem update --system
|
|
10
|
-
- gem install bundler
|
|
11
|
-
|
|
12
|
-
rvm:
|
|
13
|
-
- 2.3.8
|
|
14
|
-
- 2.4.6
|
|
15
|
-
- 2.5.5
|
|
16
|
-
- 2.6.3
|
|
17
|
-
- ruby-head
|
|
18
|
-
- jruby-9.2.7.0
|
|
19
|
-
- jruby-head
|
|
20
|
-
|
|
21
|
-
gemfile:
|
|
22
|
-
- gemfiles/rails_42.gemfile
|
|
23
|
-
- gemfiles/rails_50.gemfile
|
|
24
|
-
- gemfiles/rails_51.gemfile
|
|
25
|
-
- gemfiles/rails_52.gemfile
|
|
26
|
-
- gemfiles/rails_60.gemfile
|
|
27
|
-
- gemfiles/rails_edge.gemfile
|
|
28
|
-
|
|
29
|
-
matrix:
|
|
30
|
-
exclude:
|
|
31
|
-
- rvm: 2.3.8
|
|
32
|
-
gemfile: gemfiles/rails_60.gemfile
|
|
33
|
-
- rvm: 2.3.8
|
|
34
|
-
gemfile: gemfiles/rails_edge.gemfile
|
|
35
|
-
- rvm: 2.4.6
|
|
36
|
-
gemfile: gemfiles/rails_60.gemfile
|
|
37
|
-
- rvm: 2.4.6
|
|
38
|
-
gemfile: gemfiles/rails_edge.gemfile
|
|
39
|
-
- rvm: 2.6.3
|
|
40
|
-
gemfile: gemfiles/rails_42.gemfile
|
|
41
|
-
- rvm: ruby-head
|
|
42
|
-
gemfile: gemfiles/rails_42.gemfile
|
|
43
|
-
- rvm: ruby-head
|
|
44
|
-
gemfile: gemfiles/rails_50.gemfile
|
|
45
|
-
- rvm: ruby-head
|
|
46
|
-
gemfile: gemfiles/rails_51.gemfile
|
|
47
|
-
allow_failures:
|
|
48
|
-
- rvm: ruby-head
|
|
49
|
-
- rvm: jruby-9.2.7.0
|
|
50
|
-
- rvm: jruby-head
|
|
51
|
-
- gemfile: gemfiles/rails_edge.gemfile
|
data/gemfiles/rails_32.gemfile
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "activesupport", "~> 3.2.0"
|
|
6
|
-
gem "actionpack", "~> 3.2.0"
|
|
7
|
-
gem "railties", "~> 3.2.0"
|
|
8
|
-
gem "test-unit" if RUBY_VERSION >= "2.2.0"
|
|
9
|
-
gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
|
|
10
|
-
|
|
11
|
-
gemspec path: "../"
|
data/gemfiles/rails_40.gemfile
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "activesupport", "~> 4.0.0"
|
|
6
|
-
gem "actionpack", "~> 4.0.0"
|
|
7
|
-
gem "railties", "~> 4.0.0"
|
|
8
|
-
gem "test-unit" if RUBY_VERSION >= "2.2.0"
|
|
9
|
-
gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
|
|
10
|
-
|
|
11
|
-
gemspec path: "../"
|
data/gemfiles/rails_41.gemfile
DELETED