rambulance 3.0.0 → 3.2.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: 6572a6a2e77dbc135e1fb9bb830b6ef43af6e302b7ec0db304577f74a0cef088
4
- data.tar.gz: 9f1fc8a6204ef86c00525f4cfb9e71a80285a89e2f7b1b4aa82e6c10b56496b4
3
+ metadata.gz: d258a488889e8469aee921802e1ec980209878a709e6b7baa7a34111b13164c3
4
+ data.tar.gz: 3177f6eafb2e69b5744b4bdb73b00ab7a19c2b0b31257527e3aa07d286fa6934
5
5
  SHA512:
6
- metadata.gz: cdd6de274dbe0607bba3a0c63bd24ca733bde12cc1cfde13f7eccc2cfa560d6dee2efca1ff444cd9e6445d9a15ba17234683c7a3ef7c7a957245fd40f80af8ed
7
- data.tar.gz: 660ce18b77d8e10a3d042cc34768c802e4069633e966d32f7e240162eddb5a359d1a533e06d78cbaf28e288f92a8b5e2c88055da0b947fc9c4d6bbcf42c0a32a
6
+ metadata.gz: 58c01d13e0bdf2026c515b79696d72efdddb9cef89847e4a90db6189fe5a516d6786fdb594db3e36dbbaf87f4de44abe39b51fc044f7b08feee4ac052990c407
7
+ data.tar.gz: d2b980e56e9533a4d0a0ffc95c27aec009b822a307176be0341e08e255961c141120825f0dd25b208ee74fb97be5c8f7c31d7b74fe06c67620982ac4988d6823
@@ -8,6 +8,7 @@ jobs:
8
8
  strategy:
9
9
  matrix:
10
10
  ruby_version:
11
+ - '3.3'
11
12
  - '3.2'
12
13
  - '3.1'
13
14
  - '3.0'
@@ -17,6 +18,7 @@ jobs:
17
18
  - 'jruby-9.3'
18
19
  - 'jruby-9.4'
19
20
  gemfile:
21
+ - gemfiles/rails_71.gemfile
20
22
  - gemfiles/rails_70.gemfile
21
23
  - gemfiles/rails_61.gemfile
22
24
  - gemfiles/rails_60.gemfile
@@ -25,6 +27,18 @@ jobs:
25
27
  - gemfiles/rails_50.gemfile
26
28
  - gemfiles/rails_42.gemfile
27
29
  exclude:
30
+ - ruby_version: '3.3'
31
+ gemfile: gemfiles/rails_61.gemfile
32
+ - ruby_version: '3.3'
33
+ gemfile: gemfiles/rails_60.gemfile
34
+ - ruby_version: '3.3'
35
+ gemfile: gemfiles/rails_52.gemfile
36
+ - ruby_version: '3.3'
37
+ gemfile: gemfiles/rails_51.gemfile
38
+ - ruby_version: '3.3'
39
+ gemfile: gemfiles/rails_50.gemfile
40
+ - ruby_version: '3.3'
41
+ gemfile: gemfiles/rails_42.gemfile
28
42
  - ruby_version: '3.2'
29
43
  gemfile: gemfiles/rails_61.gemfile
30
44
  - ruby_version: '3.2'
@@ -55,6 +69,8 @@ jobs:
55
69
  gemfile: gemfiles/rails_50.gemfile
56
70
  - ruby_version: '3.0'
57
71
  gemfile: gemfiles/rails_42.gemfile
72
+ - ruby_version: '2.7'
73
+ gemfile: gemfiles/rails_71.gemfile
58
74
  - ruby_version: '2.7'
59
75
  gemfile: gemfiles/rails_70.gemfile
60
76
  - ruby_version: '2.7'
@@ -65,12 +81,18 @@ jobs:
65
81
  gemfile: gemfiles/rails_50.gemfile
66
82
  - ruby_version: '2.7'
67
83
  gemfile: gemfiles/rails_42.gemfile
84
+ - ruby_version: '2.6'
85
+ gemfile: gemfiles/rails_71.gemfile
68
86
  - ruby_version: '2.6'
69
87
  gemfile: gemfiles/rails_70.gemfile
70
88
  - ruby_version: '2.6'
71
89
  gemfile: gemfiles/rails_42.gemfile
90
+ - ruby_version: '2.5'
91
+ gemfile: gemfiles/rails_71.gemfile
72
92
  - ruby_version: '2.5'
73
93
  gemfile: gemfiles/rails_70.gemfile
94
+ - ruby_version: 'jruby-9.3'
95
+ gemfile: gemfiles/rails_71.gemfile
74
96
  - ruby_version: 'jruby-9.3'
75
97
  gemfile: gemfiles/rails_70.gemfile
76
98
  - ruby_version: 'jruby-9.3'
@@ -93,7 +115,7 @@ jobs:
93
115
  env:
94
116
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
95
117
  steps:
96
- - uses: actions/checkout@v3
118
+ - uses: actions/checkout@v4
97
119
  - name: Set up Ruby
98
120
  uses: ruby/setup-ruby@v1
99
121
  with:
@@ -108,11 +130,11 @@ jobs:
108
130
  env:
109
131
  BUNDLE_GEMFILE: gemfiles/rails_edge.gemfile
110
132
  steps:
111
- - uses: actions/checkout@v3
133
+ - uses: actions/checkout@v4
112
134
  - name: Set up Ruby
113
135
  uses: ruby/setup-ruby@v1
114
136
  with:
115
- ruby-version: 3.2
137
+ ruby-version: 3.3
116
138
  bundler-cache: true
117
139
  - run: bundle exec rake
118
140
 
@@ -126,12 +148,12 @@ jobs:
126
148
  - 'jruby-head'
127
149
  gemfile:
128
150
  - gemfiles/rails_edge.gemfile
129
- - gemfiles/rails_70.gemfile
151
+ - gemfiles/rails_71.gemfile
130
152
  runs-on: ubuntu-22.04
131
153
  env:
132
154
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
133
155
  steps:
134
- - uses: actions/checkout@v3
156
+ - uses: actions/checkout@v4
135
157
  - name: Set up Ruby
136
158
  uses: ruby/setup-ruby@v1
137
159
  with:
data/Appraisals CHANGED
@@ -44,9 +44,9 @@ appraise "rails_70" do
44
44
  end
45
45
 
46
46
  appraise "rails_71" do
47
- gem "activesupport", "~> 7.1.0.beta1"
48
- gem "actionpack", "~> 7.1.0.beta1"
49
- gem "railties", "~> 7.1.0.beta1"
47
+ gem "activesupport", "~> 7.1.0"
48
+ gem "actionpack", "~> 7.1.0"
49
+ gem "railties", "~> 7.1.0"
50
50
  end
51
51
 
52
52
  appraise "rails_edge" do
data/CHANGELOG.md CHANGED
@@ -1,12 +1,31 @@
1
- ## v3.0.0
1
+ ## v3.2.0
2
+
3
+ _<sup>unreleased</sup>_
4
+
5
+ #### New Features
6
+
7
+ - Fix the compatibility with Rack (see https://github.com/rack/rack/pull/2137) (#77 @tmaier, #78)
8
+ #
9
+ # [v3.1.0](https://github.com/yuki24/rambulance/tree/v3.1.0)
10
+
11
+ _<sup>released at 2024-01-04 10:08:11 UTC</sup>_
12
+
13
+ #### New Features
14
+
15
+ - The test helper is now compatible with Rails Edge (8.0) ([#73](https://github.com/yuki24/rambulance/pull/73), [#75](https://github.com/yuki24/rambulance/pull/75))
16
+ - Add support for Ruby 3.3 ([#74](https://github.com/yuki24/rambulance/pull/74))
17
+
18
+ ## [v3.0.0](https://github.com/yuki24/rambulance/tree/v3.0.0)
19
+
20
+ _<sup>released at 2023-09-22 14:47:24 UTC</sup>_
2
21
 
3
22
  #### New Features
4
23
 
5
- - Add support for Rails 7.1 (`be6f129d`)
24
+ - Add support for Rails 7.1 ([<tt>be6f129</tt>](https://github.com/yuki24/rambulance/commit/be6f129dd4c1d190e90a3036f7f1099028ef4a1e))
6
25
 
7
26
  #### Breaking Changes
8
27
 
9
- - Drop support for Ruby 2.3 and 2.4 (`c0d3439d`)
28
+ - Drop support for Ruby 2.3 and 2.4 ([<tt>c0d3439</tt>](https://github.com/yuki24/rambulance/commit/c0d3439d64552a88cb934d57bc57d2c06ff593c9))
10
29
 
11
30
  ## [v2.3.0](https://github.com/yuki24/rambulance/tree/v2.3.0)
12
31
 
data/README.md CHANGED
@@ -48,7 +48,7 @@ Then do the following:
48
48
  ```ruby
49
49
  # config/initializers/rambulance.rb
50
50
  config.rescue_responses = {
51
- "ActiveRecord::RecordNotUnique" => :unprocessable_entity,
51
+ "ActiveRecord::RecordNotUnique" => :unprocessable_content,
52
52
  "CanCan::AccessDenied" => :forbidden,
53
53
  "YourCustomException" => :not_found
54
54
  }
@@ -83,7 +83,7 @@ If you want to do some more things in a exceptions app, you can also write your
83
83
  $ rails g rambulance:exceptions_app
84
84
  ```
85
85
 
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`!
86
+ It will generate your own custom exceptions app. You can use most techniques you want to use in controllers like `before_filter` and rendering views since it's a grandchild of `ActionController::Base`! However there are still some restrictions, e.g. setting a flash notice works when rendering directly but not when redirecting because the ActionDispatch::Flash middleware is never hit.
87
87
 
88
88
  **Heavily customizing the exceptions app is strongly discouraged as there would be no guard against bugs that occur in the exceptions app.**
89
89
 
@@ -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, 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
126
+ * Ruby 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3 and JRuby 9.3, 9.4
127
+ * Rails 4.2, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0, 7.1 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
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "~> 7.1.0.beta1"
6
- gem "actionpack", "~> 7.1.0.beta1"
7
- gem "railties", "~> 7.1.0.beta1"
5
+ gem "activesupport", "~> 7.1.0"
6
+ gem "actionpack", "~> 7.1.0"
7
+ gem "railties", "~> 7.1.0"
8
8
 
9
9
  gemspec path: "../"
@@ -11,6 +11,6 @@ class ExceptionsApp < Rambulance::ExceptionsApp
11
11
  def not_found
12
12
  end
13
13
 
14
- def unprocessable_entity
14
+ def unprocessable_content
15
15
  end
16
16
  end
@@ -15,7 +15,7 @@ Rambulance.setup do |config|
15
15
  # If Rambulance receives an exception that is not listed here, it'll render
16
16
  # the internal server error template and return 500 as http status.
17
17
  config.rescue_responses = {
18
- # "ActiveRecord::RecordNotUnique" => :unprocessable_entity,
18
+ # "ActiveRecord::RecordNotUnique" => :unprocessable_content,
19
19
  # "CanCan::AccessDenied" => :forbidden,
20
20
  # "Pundit::NotAuthorizedError" => :forbidden,
21
21
  # "YourCustomException" => :not_found
@@ -49,7 +49,7 @@
49
49
  }
50
50
  </style>
51
51
 
52
- <!-- This file lives in app/views/errors/unprocessable_entity.html.erb -->
52
+ <!-- This file lives in app/views/errors/unprocessable_content.html.erb -->
53
53
  <div class="dialog">
54
54
  <div>
55
55
  <h1>The change you wanted was rejected.</h1>
@@ -38,7 +38,11 @@ module Rambulance
38
38
  end
39
39
  end
40
40
 
41
- action(status_in_words).call(env)
41
+ if exception.nil? && status_in_words == :unprocessable_entity
42
+ [302, { "Location" => "/rambulance/unprocessable_content" }, [""]]
43
+ else
44
+ action(status_in_words).call(env)
45
+ end
42
46
  end
43
47
 
44
48
  def self.local_prefixes
@@ -53,6 +57,12 @@ module Rambulance
53
57
  ACTION
54
58
  end
55
59
 
60
+ def unprocessable_entity
61
+ unprocessable_content_path = error_path(:unprocessable_content)
62
+
63
+ render(template_exists?(unprocessable_content_path) ? unprocessable_content_path : error_path(:internal_server_error))
64
+ end
65
+
56
66
  def process(action, *args)
57
67
  if action.to_s.empty?
58
68
  action = request.env["PATH_INFO"][1..-1].to_sym
@@ -28,7 +28,12 @@ module Rambulance #:nodoc:
28
28
  org_show_exceptions = Rails.application.env_config['action_dispatch.show_exceptions']
29
29
 
30
30
  Rails.application.env_config['action_dispatch.show_detailed_exceptions'] = !enabled
31
- Rails.application.env_config['action_dispatch.show_exceptions'] = enabled
31
+
32
+ if ActionDispatch::ExceptionWrapper.instance_methods.include?(:show?)
33
+ Rails.application.env_config['action_dispatch.show_exceptions'] = enabled ? :all : :none
34
+ else
35
+ Rails.application.env_config['action_dispatch.show_exceptions'] = enabled
36
+ end
32
37
 
33
38
  yield
34
39
  ensure
@@ -37,4 +42,3 @@ module Rambulance #:nodoc:
37
42
  end
38
43
  end
39
44
  end
40
-
@@ -1,3 +1,3 @@
1
1
  module Rambulance
2
- VERSION = "3.0.0"
2
+ VERSION = "3.2.0"
3
3
  end
@@ -6,4 +6,10 @@ class ExeptionsAppTest < ActionDispatch::IntegrationTest
6
6
 
7
7
  assert_equal 404, response.status
8
8
  end
9
+
10
+ test 'returns 302 for unprocessable_entity' do
11
+ get '/rambulance/unprocessable_entity', headers: { 'Accept' => '*/*' }
12
+
13
+ assert_redirected_to '/rambulance/unprocessable_content'
14
+ end
9
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rambulance
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Nishijima
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-09-22 00:00:00.000000000 Z
12
+ date: 2024-08-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -178,8 +178,8 @@ files:
178
178
  - lib/generators/rambulance/templates/views/not_acceptable.text.erb
179
179
  - lib/generators/rambulance/templates/views/not_found.html.erb
180
180
  - lib/generators/rambulance/templates/views/not_found.json.jbuilder
181
- - lib/generators/rambulance/templates/views/unprocessable_entity.html.erb
182
- - lib/generators/rambulance/templates/views/unprocessable_entity.json.jbuilder
181
+ - lib/generators/rambulance/templates/views/unprocessable_content.html.erb
182
+ - lib/generators/rambulance/templates/views/unprocessable_content.json.jbuilder
183
183
  - lib/rambulance.rb
184
184
  - lib/rambulance/engine.rb
185
185
  - lib/rambulance/exceptions_app.rb
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  - !ruby/object:Gem::Version
224
224
  version: '0'
225
225
  requirements: []
226
- rubygems_version: 3.4.19
226
+ rubygems_version: 3.5.11
227
227
  signing_key:
228
228
  specification_version: 4
229
229
  summary: Simple and safe way to dynamically generate error pages