rambulance 0.6.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56cafb27235f043f1b05600421ba5a01671aa3cd10d9f56beea8b29554e158a9
4
- data.tar.gz: 78329235f2a74d2250f33cf80ab32c1312a507808a056a74a1b12c8fe956cdd3
3
+ metadata.gz: 88ab78d4adf6b58a2a0206350009d9cf58577837d3a7dc9fc5bef1ca25fe23d5
4
+ data.tar.gz: 6f24e7cbf7a825b5e762e626e2799ad0491fcb46f0c3ea7cbbb72e397ee43e9f
5
5
  SHA512:
6
- metadata.gz: 6d64689dae226f3d81305cf569f8de5ea5d90a261de6dd305441dfb231b5565f3821681de0d88895019953d2db6b50829b3c2dde3dcd8c919b4b430f844d3cff
7
- data.tar.gz: 3783088dae915e9ac27897858dedb939017fc82d4bda229db4d10ea629bad01e1d14cdfef195e1c04877bee893fda0ae4e258df507d4f0f7552b5c992b05dba3
6
+ metadata.gz: 82ae05f28f01beb391c7988a6f993d76b1a81596d5da73645284e22f5328a78cc1294bd4e5f96c5603cb82872e69a057f6e620ed44221ee4a18e68d313b5016a
7
+ data.tar.gz: 432400598a5d82a59f7f1613d2443b320c1ab7943465183bd70258df9581d5ddd77b06117f98d54e452a990c05277100195fd584f15c086c6fd40598776a02aa
@@ -0,0 +1,154 @@
1
+ name: build
2
+
3
+ on:
4
+ - push
5
+
6
+ jobs:
7
+ stable:
8
+ strategy:
9
+ matrix:
10
+ ruby_version:
11
+ - '3.2'
12
+ - '3.1'
13
+ - '3.0'
14
+ - '2.7'
15
+ - '2.6'
16
+ - '2.5'
17
+ - '2.4'
18
+ - '2.3'
19
+ - 'jruby-9.3'
20
+ - 'jruby-9.4'
21
+ gemfile:
22
+ - gemfiles/rails_70.gemfile
23
+ - gemfiles/rails_61.gemfile
24
+ - gemfiles/rails_60.gemfile
25
+ - gemfiles/rails_52.gemfile
26
+ - gemfiles/rails_51.gemfile
27
+ - gemfiles/rails_50.gemfile
28
+ - gemfiles/rails_42.gemfile
29
+ exclude:
30
+ - ruby_version: '3.2'
31
+ gemfile: gemfiles/rails_61.gemfile
32
+ - ruby_version: '3.2'
33
+ gemfile: gemfiles/rails_60.gemfile
34
+ - ruby_version: '3.2'
35
+ gemfile: gemfiles/rails_52.gemfile
36
+ - ruby_version: '3.2'
37
+ gemfile: gemfiles/rails_51.gemfile
38
+ - ruby_version: '3.2'
39
+ gemfile: gemfiles/rails_50.gemfile
40
+ - ruby_version: '3.2'
41
+ gemfile: gemfiles/rails_42.gemfile
42
+ - ruby_version: '3.1'
43
+ gemfile: gemfiles/rails_60.gemfile
44
+ - ruby_version: '3.1'
45
+ gemfile: gemfiles/rails_52.gemfile
46
+ - ruby_version: '3.1'
47
+ gemfile: gemfiles/rails_51.gemfile
48
+ - ruby_version: '3.1'
49
+ gemfile: gemfiles/rails_50.gemfile
50
+ - ruby_version: '3.1'
51
+ gemfile: gemfiles/rails_42.gemfile
52
+ - ruby_version: '3.0'
53
+ gemfile: gemfiles/rails_52.gemfile
54
+ - ruby_version: '3.0'
55
+ gemfile: gemfiles/rails_51.gemfile
56
+ - ruby_version: '3.0'
57
+ gemfile: gemfiles/rails_50.gemfile
58
+ - ruby_version: '3.0'
59
+ gemfile: gemfiles/rails_42.gemfile
60
+ - ruby_version: '2.7'
61
+ gemfile: gemfiles/rails_70.gemfile
62
+ - ruby_version: '2.7'
63
+ gemfile: gemfiles/rails_52.gemfile
64
+ - ruby_version: '2.7'
65
+ gemfile: gemfiles/rails_51.gemfile
66
+ - ruby_version: '2.7'
67
+ gemfile: gemfiles/rails_50.gemfile
68
+ - ruby_version: '2.7'
69
+ gemfile: gemfiles/rails_42.gemfile
70
+ - ruby_version: '2.6'
71
+ gemfile: gemfiles/rails_70.gemfile
72
+ - ruby_version: '2.6'
73
+ gemfile: gemfiles/rails_42.gemfile
74
+ - ruby_version: '2.5'
75
+ gemfile: gemfiles/rails_70.gemfile
76
+ - ruby_version: '2.4'
77
+ gemfile: gemfiles/rails_70.gemfile
78
+ - ruby_version: '2.4'
79
+ gemfile: gemfiles/rails_61.gemfile
80
+ - ruby_version: '2.4'
81
+ gemfile: gemfiles/rails_60.gemfile
82
+ - ruby_version: '2.3'
83
+ gemfile: gemfiles/rails_70.gemfile
84
+ - ruby_version: '2.3'
85
+ gemfile: gemfiles/rails_61.gemfile
86
+ - ruby_version: '2.3'
87
+ gemfile: gemfiles/rails_60.gemfile
88
+ - ruby_version: 'jruby-9.3'
89
+ gemfile: gemfiles/rails_70.gemfile
90
+ - ruby_version: 'jruby-9.3'
91
+ gemfile: gemfiles/rails_51.gemfile
92
+ - ruby_version: 'jruby-9.3'
93
+ gemfile: gemfiles/rails_50.gemfile
94
+ - ruby_version: 'jruby-9.3'
95
+ gemfile: gemfiles/rails_42.gemfile
96
+ - ruby_version: 'jruby-9.4'
97
+ gemfile: gemfiles/rails_60.gemfile
98
+ - ruby_version: 'jruby-9.4'
99
+ gemfile: gemfiles/rails_52.gemfile
100
+ - ruby_version: 'jruby-9.4'
101
+ gemfile: gemfiles/rails_51.gemfile
102
+ - ruby_version: 'jruby-9.4'
103
+ gemfile: gemfiles/rails_50.gemfile
104
+ - ruby_version: 'jruby-9.4'
105
+ gemfile: gemfiles/rails_42.gemfile
106
+ runs-on: ubuntu-22.04
107
+ env:
108
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
109
+ steps:
110
+ - uses: actions/checkout@v3
111
+ - name: Set up Ruby
112
+ uses: ruby/setup-ruby@v1
113
+ with:
114
+ ruby-version: ${{ matrix.ruby_version }}
115
+ bundler-cache: true
116
+ - run: bundle exec rake
117
+
118
+ rails_edge:
119
+ needs:
120
+ - stable
121
+ runs-on: ubuntu-22.04
122
+ env:
123
+ BUNDLE_GEMFILE: gemfiles/rails_edge.gemfile
124
+ steps:
125
+ - uses: actions/checkout@v3
126
+ - name: Set up Ruby
127
+ uses: ruby/setup-ruby@v1
128
+ with:
129
+ ruby-version: 3.2
130
+ bundler-cache: true
131
+ - run: bundle exec rake
132
+
133
+ ruby_edge:
134
+ needs:
135
+ - stable
136
+ strategy:
137
+ matrix:
138
+ ruby_version:
139
+ - 'ruby-head'
140
+ - 'jruby-head'
141
+ gemfile:
142
+ - gemfiles/rails_edge.gemfile
143
+ - gemfiles/rails_70.gemfile
144
+ runs-on: ubuntu-22.04
145
+ env:
146
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
147
+ steps:
148
+ - uses: actions/checkout@v3
149
+ - name: Set up Ruby
150
+ uses: ruby/setup-ruby@v1
151
+ with:
152
+ ruby-version: ${{ matrix.ruby_version }}
153
+ bundler-cache: true
154
+ - 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"
@@ -43,13 +20,31 @@ appraise "rails_51" do
43
20
  end
44
21
 
45
22
  appraise "rails_52" do
46
- gem "activesupport", "~> 5.2.0.rc1"
47
- gem "actionpack", "~> 5.2.0.rc1"
48
- gem "railties", "~> 5.2.0.rc1"
23
+ gem "activesupport", "~> 5.2.0"
24
+ gem "actionpack", "~> 5.2.0"
25
+ gem "railties", "~> 5.2.0"
26
+ end
27
+
28
+ appraise "rails_60" do
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"
49
44
  end
50
45
 
51
46
  appraise "rails_edge" do
52
- git 'git://github.com/rails/rails.git' do
47
+ git 'https://github.com/rails/rails.git' do
53
48
  gem "activesupport", require: 'active_support'
54
49
  gem "actionpack", require: 'action_pack'
55
50
  gem "railties"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,102 @@
1
+ ## v2.2.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
+
52
+ ## [v1.0.2](https://github.com/yuki24/rambulance/tree/v1.0.2)
53
+
54
+ _<sup>released at 2019-06-06 23:39:38 UTC</sup>_
55
+
56
+ #### Fixes
57
+
58
+ - Fixes a bug where `ExceptionsApp` is not loaded when action controller is not loaded ([<tt>ec9d9e5</tt>](https://github.com/yuki24/rambulance/commit/ec9d9e5de98eeec501042a0bbb95ae8ac8d7b4e3))
59
+
60
+ ## [v1.0.1](https://github.com/yuki24/rambulance/tree/v1.0.1)
61
+
62
+ _<sup>released at 2019-06-04 16:30:38 UTC</sup>_
63
+
64
+ #### Fixes
65
+
66
+ - Fixes an issue where `ExceptionsApp` prevents Rails from booting up ([#49](https://github.com/yuki24/rambulance/issues/49))
67
+
68
+ ## [v1.0.0](https://github.com/yuki24/rambulance/tree/v1.0.0)
69
+
70
+ _<sup>released at 2019-06-03 05:01:14 UTC</sup>_
71
+
72
+ #### Features
73
+
74
+ - Add support for Ruby 2.6
75
+ - Add support for Rails 6.0
76
+
77
+ #### Bug fixes
78
+
79
+ - Fixes a bug where POST requests cause the exceptions app to throw an `ActionController::InvalidAuthenticityToken` error on Rails 5.2 ([<tt>d68d677</tt>](https://github.com/yuki24/rambulance/commit/d68d677de75059fa09f70e37c97f4bae95885c53), [#48](https://github.com/yuki24/rambulance/issues/48), [@adrianhuna](https://github.com/adrianhuna))
80
+
81
+ #### Breaking Changes
82
+
83
+ - Drop support for Ruby \<= 2.2
84
+ - Drop support for Rails \<= 4.1
85
+
86
+ ## [v0.6.0](https://github.com/yuki24/rambulance/tree/v0.6.0)
87
+
88
+ _<sup>released at 2018-03-08 18:36:16 UTC</sup>_
89
+
90
+ #### New features
91
+
92
+ - Add support for Rails 5.2
93
+ - Add a test helper method `#with_exceptions_app` for easier testing ([<tt>f5c16b9</tt>](https://github.com/yuki24/rambulance/commit/f5c16b90ecf5eb4903faa30d760bf5863441e9c5), [#27](https://github.com/yuki24/rambulance/pull/27), [@kbaba1001](https://github.com/kbaba1001))
94
+
95
+ #### Bug fixes
96
+
97
+ - Fixed a bug where an `ActionController::UnknownFormat` error could cause a number of issues ([<tt>1b824e6</tt>](https://github.com/yuki24/rambulance/commit/1b824e6c170479ed90e24df1680dd2dec7c98160), [#41](https://github.com/yuki24/rambulance/issues/41), [#42](https://github.com/yuki24/rambulance/pull/42), [@willnet](https://github.com/willnet), [@joker-777](https://github.com/joker-777))
98
+ - Fixed a bug where the methods on the `ExceptionApp` weren't easily inspectable ([<tt>6b4c834</tt>](https://github.com/yuki24/rambulance/commit/6b4c834bb0b8e81f619d9f598310ce68f4f9c66b))
99
+
1
100
  ## [v0.5.0](https://github.com/yuki24/rambulance/tree/v0.5.0)
2
101
 
3
102
  _<sup>released at 2018-01-02 21:36:02 UTC</sup>_
data/Dangerfile ADDED
@@ -0,0 +1,13 @@
1
+ # Sometimes it's a README fix, or something like that - which isn't relevant for
2
+ # including in a project's CHANGELOG for example
3
+ declared_trivial = github.pr_title.include? "#trivial"
4
+
5
+ # Make it more obvious that a PR is a work in progress and shouldn't be merged yet
6
+ warn("PR is classed as Work in Progress") if github.pr_title.include? "WIP"
7
+
8
+ # Warn when there is a big PR
9
+ warn("Big PR") if git.lines_of_code > 500
10
+
11
+ # Don't let testing shortcuts get into master by accident
12
+ fail("fdescribe left in tests") if `grep -r fdescribe test/ `.length > 1
13
+ fail("fit left in tests") if `grep -r fit test/ `.length > 1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Rambulance [![Build Status](https://travis-ci.org/yuki24/rambulance.svg?branch=master)](https://travis-ci.org/yuki24/rambulance)
1
+ # Rambulance [![build](https://github.com/yuki24/rambulance/actions/workflows/tests.yml/badge.svg)](https://github.com/yuki24/rambulance/actions/workflows/tests.yml) [![Gem Version](https://badge.fury.io/rb/rambulance.svg)](https://rubygems.org/gems/rambulance)
2
2
 
3
- Rambulance provides a simple and safe way to dynamically render error pages for Rails apps.
3
+ A simple and safe way to dynamically render error pages for Rails apps.
4
4
 
5
5
  ## Features
6
6
 
@@ -10,7 +10,7 @@ Rambulance's exceptions app is simple, skinny and well-tested. It inherits from
10
10
 
11
11
  ### Flexible
12
12
 
13
- You have full control of showing a specific error page for a specific exception. It can also render json responses. It even provides a way to create a custom exceptions app.
13
+ You have full control of which error page to show for a specific exception. It also json rendering (perfect for API apps). It even provides a way to create a custom exceptions app.
14
14
 
15
15
  ### Easy installation and development
16
16
 
@@ -30,7 +30,7 @@ And then execute:
30
30
  $ rails g rambulance:install
31
31
  ```
32
32
 
33
- Rambulance only has support for `erb`. If you would like to use haml or slim templates, please see [How to Convert Your `.erb` to `.slim`](https://github.com/slim-template/slim/wiki/Template-Converters-ERB-to-SLIM) or [html2haml](https://github.com/haml/html2haml).
33
+ Rambulance's generator can only generate `erb` templates. If you want to use haml or slim templates, please see [How to Convert Your `.erb` to `.slim`](https://github.com/slim-template/slim/wiki/Template-Converters-ERB-to-SLIM) or [html2haml](https://github.com/haml/html2haml).
34
34
 
35
35
  Now you can start editing templates like `app/views/errors/not_found.html.erb`. Edit, run `rails server` and open [`localhost:3000/rambulance/not_found`](http://localhost:3000/rambulance/not_found)!
36
36
 
@@ -56,19 +56,10 @@ config.rescue_responses = {
56
56
 
57
57
  ## Local Development
58
58
 
59
- There are 2 ways of editing the templates.
60
-
61
- <!---
62
- ### Open [`localhost:3000/rambulance`](http://localhost:3000/rambulance) in Your Browser
63
-
64
- This page tells all the error pages as well as all the pairs of exceptions/corresponding http status. This is useful when you want to edit templates without changing Rails configuration. Click on one of the links in the page to see what the error page looks like.
65
-
66
- **This feature hasn't been implemented yet.**
67
- -->
68
-
69
59
  ### Open `localhost:3000/rambulance/***` in Your Browser
70
60
 
71
- Just go to one of the error pages via Rambulance:
61
+ Just open one of the error pages via Rambulance:
62
+
72
63
  * [`localhost:3000/rambulance/not_found`](http://localhost:3000/rambulance/not_found) or
73
64
  * [`localhost:3000/rambulance/internal_server_error`](http://localhost:3000/rambulance/internal_server_error)
74
65
 
@@ -78,7 +69,7 @@ This is useful when you want to edit templates without changing Rails configurat
78
69
 
79
70
  Change `config.consider_all_requests_local` to _false_ in `config/environments/development.rb`.
80
71
 
81
- ```
72
+ ```ruby
82
73
  config.consider_all_requests_local = false
83
74
  ```
84
75
 
@@ -88,17 +79,17 @@ This simulates how your production app displays error pages so you can actually
88
79
 
89
80
  If you want to do some more things in a exceptions app, you can also write your own custom exceptions app:
90
81
 
91
- ```
82
+ ```sh
92
83
  $ rails g rambulance:exceptions_app
93
84
  ```
94
85
 
95
- It'll generate your own custom exceptions app. You can use whatever techniques you use in controllers like `before_filter` and `flash[:notice] = "message..."` since it's a grandchild of `ActionController::Base`!
86
+ It will generate your own custom exceptions app. You can use whatever techniques you want to use in controllers like `before_filter` and `flash[:notice] = "message..."` since it's a grandchild of `ActionController::Base`!
96
87
 
97
- **Keep in mind that you shouldn't do too many things because something already went wrong with your application!**
88
+ **Heavily customizing the exceptions app is strongly discouraged as there would be no guard against bugs that occur in the exceptions app.**
98
89
 
99
90
  ## Testing
100
91
 
101
- Ramnurance ships with a test helper that allows you to test an error page generated by Rails. All you have to do is to `include Rambulance::TestHelper` and you will be able to use the `with_exceptions_app` DSDL:
92
+ Rambulance ships with a test helper that allows you to test an error page generated by Rails. All you have to do is to `include Rambulance::TestHelper` and you will be able to use the `with_exceptions_app` DSDL:
102
93
 
103
94
  Rspec:
104
95
 
@@ -132,8 +123,8 @@ Note that testing error pages is not encouraged in Rails as it leads to overuse
132
123
 
133
124
  ## Supported Versions
134
125
 
135
- * Ruby 2.0.0, 2.1, 2.2, 2.3, 2,4, 2,5, trunk, JRuby 9.1.16.0, and JRuby head
136
- * Rails 3.2, 4.0, 4.1, 4.2, 5.0, 5,1, 5,2 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
137
128
 
138
129
  Rambulance doesn't work with Rails 3.1 and below since they don't provide a way to use a custom exceptions app.
139
130
 
@@ -6,6 +6,5 @@ gem "activesupport", "~> 4.2.0"
6
6
  gem "actionpack", "~> 4.2.0"
7
7
  gem "railties", "~> 4.2.0"
8
8
  gem "minitest", "~> 5.3.4"
9
- gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
10
9
 
11
10
  gemspec path: "../"
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "~> 5.2.0.rc1"
6
- gem "actionpack", "~> 5.2.0.rc1"
7
- gem "railties", "~> 5.2.0.rc1"
5
+ gem "activesupport", "~> 5.2.0"
6
+ gem "actionpack", "~> 5.2.0"
7
+ gem "railties", "~> 5.2.0"
8
8
 
9
9
  gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 6.0.0"
6
+ gem "actionpack", "~> 6.0.0"
7
+ gem "railties", "~> 6.0.0"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 6.1.0"
6
+ gem "actionpack", "~> 6.1.0"
7
+ gem "railties", "~> 6.1.0"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 7.0.0"
6
+ gem "actionpack", "~> 7.0.0"
7
+ gem "railties", "~> 7.0.0"
8
+
9
+ gemspec path: "../"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- git "git://github.com/rails/rails.git" do
5
+ git "https://github.com/rails/rails.git" do
6
6
  gem "activesupport", require: "active_support"
7
7
  gem "actionpack", require: "action_pack"
8
8
  gem "railties"
@@ -22,12 +22,12 @@ Rambulance.setup do |config|
22
22
  }
23
23
 
24
24
  # The template name for the layout of the error pages. The default value is
25
- # 'error'. For exmaple, if this value is set to "error_page", Rambulance uses
25
+ # 'error'. For example, if this value is set to "error_page", Rambulance uses
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 directry name to organize error page templates. The default value is
30
- # 'errors'. For exmaple, if this value is set to "error_pages", Rambulance
29
+ # The directory name to organize error page templates. The default value is
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"
33
33
 
@@ -9,14 +9,24 @@ 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
 
15
- BAD_REQUEST_EXCEPTION = begin
16
- ActionController::BadRequest
17
- rescue NameError
18
- TypeError # Rails 3.2 doesn't know about ActionController::BadRequest
19
- end
25
+ begin
26
+ skip_forgery_protection
27
+ rescue
28
+ # ignore errors from #skip_forgery_protection since older Rails adds this method later.
29
+ end
20
30
 
21
31
  def self.call(env)
22
32
  exception = env["action_dispatch.exception"]
@@ -33,7 +43,7 @@ module Rambulance
33
43
 
34
44
  def self.local_prefixes
35
45
  [Rambulance.view_path]
36
- end if ActionPack::VERSION::STRING >= "4.2.0"
46
+ end
37
47
 
38
48
  ERROR_HTTP_STATUSES.values.each do |status_in_words|
39
49
  eval <<-ACTION, nil, __FILE__, __LINE__ + 1
@@ -55,26 +65,33 @@ 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
- rescue BAD_REQUEST_EXCEPTION
76
+ rescue ActionController::BadRequest
61
77
  request.env["MALFORMED_QUERY_STRING"], request.env["QUERY_STRING"] = request.env["QUERY_STRING"], ""
62
78
  end
63
79
 
64
80
  begin
65
81
  request.POST
66
- rescue BAD_REQUEST_EXCEPTION, ArgumentError
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
 
70
- # The #formats method needs to be called after the sanitization above.
71
- if request.respond_to?(:formats)
72
- request.formats << Mime::Type.lookup('text/plain')
73
- elsif request.respond_to?(:format) && status == 406
74
- # TODO: Remove this conditional when dropping support for Rails 3.2
75
- request.format = Mime::Type.lookup('text/plain')
86
+ begin
87
+ request.accepts
88
+ rescue Mime::Type::InvalidMimeType
89
+ request.env["MALFORMED_HTTP_ACCEPT"], request.env["HTTP_ACCEPT"] = request.env["HTTP_ACCEPT"], "*/*"
76
90
  end
77
91
 
92
+ # The #formats method needs to be called after the sanitization above.
93
+ request.formats << Mime::Type.lookup('text/plain')
94
+
78
95
  super
79
96
  end
80
97
 
@@ -1,14 +1,30 @@
1
1
  module Rambulance
2
2
  class Railtie < Rails::Railtie
3
3
  initializer 'rambulance', after: :prepend_helpers_path do |app|
4
- require "rambulance/exceptions_app"
4
+ ActiveSupport.on_load(:action_controller) do
5
+ require "rambulance/exceptions_app"
6
+ end
5
7
 
6
8
  app.config.exceptions_app =
7
- begin
8
- ActiveSupport::Dependencies.load_missing_constant(Object, :ExceptionsApp)
9
- ->(env){ ::ExceptionsApp.call(env) }
10
- rescue NameError
11
- ::Rambulance::ExceptionsApp
9
+ if app.config.respond_to?(:autoloader) && app.config.autoloader == :classic
10
+ ->(env) {
11
+ begin
12
+ ActiveSupport::Dependencies.load_missing_constant(Object, :ExceptionsApp)
13
+ ::ExceptionsApp.call(env)
14
+ rescue NameError
15
+ require "rambulance/exceptions_app" if !defined?(::Rambulance::ExceptionsApp)
16
+ ::Rambulance::ExceptionsApp.call(env)
17
+ end
18
+ }
19
+ else
20
+ ->(env) {
21
+ begin
22
+ ::ExceptionsApp.call(env)
23
+ rescue NameError
24
+ require "rambulance/exceptions_app" if !defined?(::Rambulance::ExceptionsApp)
25
+ ::Rambulance::ExceptionsApp.call(env)
26
+ end
27
+ }
12
28
  end
13
29
 
14
30
  ActiveSupport.on_load(:after_initialize) do
@@ -1,3 +1,3 @@
1
1
  module Rambulance
2
- VERSION = "0.6.0"
2
+ VERSION = "2.3.0"
3
3
  end
data/lib/rambulance.rb CHANGED
@@ -13,7 +13,7 @@ module Rambulance
13
13
  mattr_accessor :layout_name
14
14
  @@layout_name = "application"
15
15
 
16
- # The directry name to organize error page templates.
16
+ # The directory name to organize error page templates.
17
17
  mattr_accessor :view_path
18
18
  @@view_path = "errors"
19
19
 
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.}
@@ -8,6 +8,11 @@ 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"
12
+
13
+ if Rails::VERSION::STRING >= "5.2"
14
+ config.action_controller.default_protect_from_forgery = true
15
+ end
11
16
  end
12
17
  Rails.backtrace_cleaner.remove_silencers!
13
18
  Rails.application.initialize!
@@ -15,7 +20,7 @@ Rails.application.initialize!
15
20
  # routes
16
21
  Rails.application.routes.draw do
17
22
  resources :users
18
- resources :projects, only: :index
23
+ resources :projects, only: [:index, :create]
19
24
  end
20
25
 
21
26
  # custom exception class
@@ -46,6 +51,7 @@ class ApplicationController < ActionController::Base
46
51
  raise "This is a bad filter."
47
52
  end
48
53
  end
54
+
49
55
  class UsersController < ApplicationController
50
56
  if self.respond_to? :skip_before_action
51
57
  skip_before_action :bad_filter, except: :show
@@ -75,12 +81,18 @@ class UsersController < ApplicationController
75
81
  raise ForbiddenException
76
82
  end
77
83
  end
84
+
78
85
  class ProjectsController < ApplicationController
86
+ if self.respond_to?(:skip_forgery_protection)
87
+ skip_forgery_protection
88
+ end
89
+
79
90
  if self.respond_to? :skip_before_action
80
- skip_before_action :bad_filter
91
+ skip_before_action :bad_filter, except: :create
81
92
  else
82
- skip_filter :bad_filter
93
+ skip_filter :bad_filter, except: :create
83
94
  end
84
95
 
85
96
  def index; end
97
+ def create; end
86
98
  end
@@ -29,6 +29,66 @@ class ErrorJsonTest < ActionDispatch::IntegrationTest
29
29
  assert_equal "Page not found", json_response['message']
30
30
  end
31
31
 
32
+ test 'renders an error page on a POST request' do
33
+ post '/projects.json'
34
+
35
+ assert_equal 500, response.status
36
+ assert_equal "Something went wrong", json_response['message']
37
+ end
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
+
32
92
  private
33
93
 
34
94
  def without_layouts
@@ -41,12 +101,12 @@ class ErrorJsonTest < ActionDispatch::IntegrationTest
41
101
  `mv error.html.erb test/fake_app/app/views/layouts/`
42
102
  end
43
103
 
44
- def get(path)
104
+ def get(path, params: {}, headers: {})
45
105
  without_layouts do
46
106
  if Rails::VERSION::STRING >= '5.1.0'
47
- 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)
48
108
  else
49
- super path, nil, "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"
109
+ super path, params, { "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json" }.merge(headers)
50
110
  end
51
111
  end
52
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: 0.6.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Nishijima
8
- autorequire:
8
+ - Yoav Aner
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2018-03-08 00:00:00.000000000 Z
12
+ date: 2023-01-05 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activesupport
@@ -144,23 +145,24 @@ 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
152
+ - Dangerfile
151
153
  - Gemfile
152
154
  - LICENSE.txt
153
155
  - README.md
154
156
  - Rakefile
155
157
  - app/views/errors/internal_server_error.text.erb
156
158
  - app/views/errors/not_acceptable.text.erb
157
- - gemfiles/rails_32.gemfile
158
- - gemfiles/rails_40.gemfile
159
- - gemfiles/rails_41.gemfile
160
159
  - gemfiles/rails_42.gemfile
161
160
  - gemfiles/rails_50.gemfile
162
161
  - gemfiles/rails_51.gemfile
163
162
  - gemfiles/rails_52.gemfile
163
+ - gemfiles/rails_60.gemfile
164
+ - gemfiles/rails_61.gemfile
165
+ - gemfiles/rails_70.gemfile
164
166
  - gemfiles/rails_edge.gemfile
165
167
  - lib/generators/rambulance/exceptions_app_generator.rb
166
168
  - lib/generators/rambulance/install_generator.rb
@@ -205,7 +207,7 @@ homepage: http://github.com/yuki24/rambulance
205
207
  licenses:
206
208
  - MIT
207
209
  metadata: {}
208
- post_install_message:
210
+ post_install_message:
209
211
  rdoc_options: []
210
212
  require_paths:
211
213
  - lib
@@ -220,9 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
222
  - !ruby/object:Gem::Version
221
223
  version: '0'
222
224
  requirements: []
223
- rubyforge_project:
224
- rubygems_version: 2.7.6
225
- signing_key:
225
+ rubygems_version: 3.3.7
226
+ signing_key:
226
227
  specification_version: 4
227
228
  summary: Simple and safe way to dynamically generate error pages
228
229
  test_files:
data/.travis.yml DELETED
@@ -1,94 +0,0 @@
1
- language: ruby
2
- script: bundle exec rake
3
- cache: bundler
4
- sudo: false
5
-
6
- before_install:
7
- - gem update --system
8
- - gem pristine bundler
9
-
10
- rvm:
11
- - 2.0.0
12
- - 2.1
13
- - 2.2.9
14
- - 2.3.6
15
- - 2.4.3
16
- - 2.5.0
17
- - ruby-head
18
- - jruby-9.1.16.0
19
- - jruby-head
20
-
21
- gemfile:
22
- - gemfiles/rails_32.gemfile
23
- - gemfiles/rails_40.gemfile
24
- - gemfiles/rails_41.gemfile
25
- - gemfiles/rails_42.gemfile
26
- - gemfiles/rails_50.gemfile
27
- - gemfiles/rails_51.gemfile
28
- - gemfiles/rails_52.gemfile
29
- - gemfiles/rails_edge.gemfile
30
-
31
- matrix:
32
- exclude:
33
- - rvm: 2.0.0
34
- gemfile: gemfiles/rails_50.gemfile
35
- - rvm: 2.0.0
36
- gemfile: gemfiles/rails_51.gemfile
37
- - rvm: 2.0.0
38
- gemfile: gemfiles/rails_52.gemfile
39
- - rvm: 2.0.0
40
- gemfile: gemfiles/rails_edge.gemfile
41
- - rvm: 2.1
42
- gemfile: gemfiles/rails_50.gemfile
43
- - rvm: 2.1
44
- gemfile: gemfiles/rails_51.gemfile
45
- - rvm: 2.1
46
- gemfile: gemfiles/rails_52.gemfile
47
- - rvm: 2.1
48
- gemfile: gemfiles/rails_edge.gemfile
49
- - rvm: 2.2.9
50
- gemfile: gemfiles/rails_32.gemfile
51
- - rvm: 2.2.9
52
- gemfile: gemfiles/rails_51.gemfile
53
- - rvm: 2.2.9
54
- gemfile: gemfiles/rails_edge.gemfile
55
- - rvm: 2.3.6
56
- gemfile: gemfiles/rails_32.gemfile
57
- - rvm: 2.3.6
58
- gemfile: gemfiles/rails_edge.gemfile
59
- - rvm: 2.4.3
60
- gemfile: gemfiles/rails_32.gemfile
61
- - rvm: 2.4.3
62
- gemfile: gemfiles/rails_40.gemfile
63
- - rvm: 2.4.3
64
- gemfile: gemfiles/rails_41.gemfile
65
- - rvm: 2.5.0
66
- gemfile: gemfiles/rails_32.gemfile
67
- - rvm: 2.5.0
68
- gemfile: gemfiles/rails_40.gemfile
69
- - rvm: 2.5.0
70
- gemfile: gemfiles/rails_41.gemfile
71
- - rvm: ruby-head
72
- gemfile: gemfiles/rails_32.gemfile
73
- - rvm: ruby-head
74
- gemfile: gemfiles/rails_40.gemfile
75
- - rvm: ruby-head
76
- gemfile: gemfiles/rails_41.gemfile
77
- - rvm: jruby-9.1.16.0
78
- gemfile: gemfiles/rails_32.gemfile
79
- - rvm: jruby-9.1.16.0
80
- gemfile: gemfiles/rails_40.gemfile
81
- - rvm: jruby-9.1.16.0
82
- gemfile: gemfiles/rails_41.gemfile
83
- - rvm: jruby-head
84
- gemfile: gemfiles/rails_32.gemfile
85
- - rvm: jruby-head
86
- gemfile: gemfiles/rails_40.gemfile
87
- - rvm: jruby-head
88
- gemfile: gemfiles/rails_41.gemfile
89
- allow_failures:
90
- - rvm: ruby-head
91
- - rvm: jruby-9.1.16.0
92
- - rvm: jruby-head
93
- - gemfile: gemfiles/rails_edge.gemfile
94
- - gemfile: gemfiles/rails_32.gem
@@ -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: "../"
@@ -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: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activesupport", "~> 4.1.0"
6
- gem "actionpack", "~> 4.1.0"
7
- gem "railties", "~> 4.1.0"
8
- gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
9
-
10
- gemspec path: "../"