rambulance 0.6.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56cafb27235f043f1b05600421ba5a01671aa3cd10d9f56beea8b29554e158a9
4
- data.tar.gz: 78329235f2a74d2250f33cf80ab32c1312a507808a056a74a1b12c8fe956cdd3
3
+ metadata.gz: 4e7a19e6d38b6d44ff7cfe3cc0589f0bf8575f1e6750bf73df35096822e62d5a
4
+ data.tar.gz: cf524a57dc3237fc8a182256986fef5178d2efd7d262f85be0b18f8829522d6e
5
5
  SHA512:
6
- metadata.gz: 6d64689dae226f3d81305cf569f8de5ea5d90a261de6dd305441dfb231b5565f3821681de0d88895019953d2db6b50829b3c2dde3dcd8c919b4b430f844d3cff
7
- data.tar.gz: 3783088dae915e9ac27897858dedb939017fc82d4bda229db4d10ea629bad01e1d14cdfef195e1c04877bee893fda0ae4e258df507d4f0f7552b5c992b05dba3
6
+ metadata.gz: 8a2dd2e048ccde58d0f8f17d47d0d8f4722a7c83e57062a600c4a2c4d4455823b2d73c854ef77fa7e976db24a888f959b5d3068d059822d73fa428404f2f425e
7
+ data.tar.gz: 14753c604c06c1a6412372cd63066a5aa8af55c5c5c0fba8ef3d7764228aa8cb9d735748eb3fc023570d7c4633482f6e2ad38746a36087a781fe74a2f3d16b28
@@ -1,94 +1,51 @@
1
1
  language: ruby
2
- script: bundle exec rake
3
2
  cache: bundler
4
3
  sudo: false
5
4
 
5
+ script:
6
+ - bundle exec rake
7
+
6
8
  before_install:
7
9
  - gem update --system
8
- - gem pristine bundler
10
+ - gem install bundler
9
11
 
10
12
  rvm:
11
- - 2.0.0
12
- - 2.1
13
- - 2.2.9
14
- - 2.3.6
15
- - 2.4.3
16
- - 2.5.0
13
+ - 2.3.8
14
+ - 2.4.6
15
+ - 2.5.5
16
+ - 2.6.3
17
17
  - ruby-head
18
- - jruby-9.1.16.0
18
+ - jruby-9.2.7.0
19
19
  - jruby-head
20
20
 
21
21
  gemfile:
22
- - gemfiles/rails_32.gemfile
23
- - gemfiles/rails_40.gemfile
24
- - gemfiles/rails_41.gemfile
25
22
  - gemfiles/rails_42.gemfile
26
23
  - gemfiles/rails_50.gemfile
27
24
  - gemfiles/rails_51.gemfile
28
25
  - gemfiles/rails_52.gemfile
26
+ - gemfiles/rails_60.gemfile
29
27
  - gemfiles/rails_edge.gemfile
30
28
 
31
29
  matrix:
32
30
  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
31
+ - rvm: 2.3.8
32
+ gemfile: gemfiles/rails_60.gemfile
33
+ - rvm: 2.3.8
40
34
  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
35
+ - rvm: 2.4.6
36
+ gemfile: gemfiles/rails_60.gemfile
37
+ - rvm: 2.4.6
54
38
  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
39
+ - rvm: 2.6.3
40
+ gemfile: gemfiles/rails_42.gemfile
71
41
  - rvm: ruby-head
72
- gemfile: gemfiles/rails_32.gemfile
42
+ gemfile: gemfiles/rails_42.gemfile
73
43
  - rvm: ruby-head
74
- gemfile: gemfiles/rails_40.gemfile
44
+ gemfile: gemfiles/rails_50.gemfile
75
45
  - 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
46
+ gemfile: gemfiles/rails_51.gemfile
89
47
  allow_failures:
90
48
  - rvm: ruby-head
91
- - rvm: jruby-9.1.16.0
49
+ - rvm: jruby-9.2.7.0
92
50
  - rvm: jruby-head
93
51
  - gemfile: gemfiles/rails_edge.gemfile
94
- - gemfile: gemfiles/rails_32.gem
data/Appraisals CHANGED
@@ -43,9 +43,15 @@ appraise "rails_51" do
43
43
  end
44
44
 
45
45
  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"
46
+ gem "activesupport", "~> 5.2.0"
47
+ gem "actionpack", "~> 5.2.0"
48
+ gem "railties", "~> 5.2.0"
49
+ end
50
+
51
+ appraise "rails_60" do
52
+ gem "activesupport", "~> 6.0.0.rc1"
53
+ gem "actionpack", "~> 6.0.0.rc1"
54
+ gem "railties", "~> 6.0.0.rc1"
49
55
  end
50
56
 
51
57
  appraise "rails_edge" do
@@ -1,3 +1,17 @@
1
+ ## [v0.6.0](https://github.com/yuki24/rambulance/tree/v0.6.0)
2
+
3
+ _<sup>released at 2018-03-08 18:36:16 UTC</sup>_
4
+
5
+ #### New features
6
+
7
+ - Add support for Rails 5.2
8
+ - 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))
9
+
10
+ #### Bug fixes
11
+
12
+ - 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))
13
+ - Fixed a bug where the methods on the `ExceptionApp` weren't easily inspectable ([<tt>6b4c834</tt>](https://github.com/yuki24/rambulance/commit/6b4c834bb0b8e81f619d9f598310ce68f4f9c66b))
14
+
1
15
  ## [v0.5.0](https://github.com/yuki24/rambulance/tree/v0.5.0)
2
16
 
3
17
  _<sup>released at 2018-01-02 21:36:02 UTC</sup>_
@@ -10,7 +24,7 @@ _<sup>released at 2018-01-02 21:36:02 UTC</sup>_
10
24
  #### Breaking changes & deprecations
11
25
 
12
26
  - Drop support for Ruby 1.9.3
13
- - Drop support for Haml and Slim templates
27
+ - Drop support for generating Haml and Slim templates on `rails g rambulance:install`
14
28
 
15
29
  #### Bug fixes
16
30
 
@@ -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
@@ -94,7 +94,7 @@ $ rails g rambulance:exceptions_app
94
94
 
95
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`!
96
96
 
97
- **Keep in mind that you shouldn't do too many things because something already went wrong with your application!**
97
+ **Note that customizing the exceptions app is strongly discouraged as there would be no guard against bugs that occur in the exceptions app.**
98
98
 
99
99
  ## Testing
100
100
 
@@ -132,8 +132,8 @@ Note that testing error pages is not encouraged in Rails as it leads to overuse
132
132
 
133
133
  ## Supported Versions
134
134
 
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
135
+ * Ruby 2.3, 2,4, 2,5, trunk, JRuby 9.1.16.0, and JRuby head
136
+ * Rails 4.2, 5.0, 5,1, 5,2 and edge
137
137
 
138
138
  Rambulance doesn't work with Rails 3.1 and below since they don't provide a way to use a custom exceptions app.
139
139
 
@@ -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.rc1"
6
+ gem "actionpack", "~> 6.0.0.rc1"
7
+ gem "railties", "~> 6.0.0.rc1"
8
+
9
+ gemspec path: "../"
@@ -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
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
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
 
@@ -12,11 +12,9 @@ module Rambulance
12
12
  class ExceptionsApp < ActionController::Base
13
13
  layout :layout_name
14
14
 
15
- BAD_REQUEST_EXCEPTION = begin
16
- ActionController::BadRequest
17
- rescue NameError
18
- TypeError # Rails 3.2 doesn't know about ActionController::BadRequest
19
- end
15
+ if self.respond_to?(:skip_forgery_protection)
16
+ skip_forgery_protection
17
+ end
20
18
 
21
19
  def self.call(env)
22
20
  exception = env["action_dispatch.exception"]
@@ -33,7 +31,7 @@ module Rambulance
33
31
 
34
32
  def self.local_prefixes
35
33
  [Rambulance.view_path]
36
- end if ActionPack::VERSION::STRING >= "4.2.0"
34
+ end
37
35
 
38
36
  ERROR_HTTP_STATUSES.values.each do |status_in_words|
39
37
  eval <<-ACTION, nil, __FILE__, __LINE__ + 1
@@ -57,23 +55,18 @@ module Rambulance
57
55
  def process_action(*)
58
56
  begin
59
57
  request.GET
60
- rescue BAD_REQUEST_EXCEPTION
58
+ rescue ActionController::BadRequest
61
59
  request.env["MALFORMED_QUERY_STRING"], request.env["QUERY_STRING"] = request.env["QUERY_STRING"], ""
62
60
  end
63
61
 
64
62
  begin
65
63
  request.POST
66
- rescue BAD_REQUEST_EXCEPTION, ArgumentError
64
+ rescue ActionController::BadRequest
67
65
  request.env["MALFORMED_BODY"], request.env["rack.input"] = request.env["rack.input"], StringIO.new
68
66
  end
69
67
 
70
68
  # 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')
76
- end
69
+ request.formats << Mime::Type.lookup('text/plain')
77
70
 
78
71
  super
79
72
  end
@@ -1,15 +1,18 @@
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
- app.config.exceptions_app =
8
+ app.config.exceptions_app = ->(env) {
7
9
  begin
8
10
  ActiveSupport::Dependencies.load_missing_constant(Object, :ExceptionsApp)
9
- ->(env){ ::ExceptionsApp.call(env) }
11
+ ::ExceptionsApp.call(env)
10
12
  rescue NameError
11
- ::Rambulance::ExceptionsApp
13
+ ::Rambulance::ExceptionsApp.call(env)
12
14
  end
15
+ }
13
16
 
14
17
  ActiveSupport.on_load(:after_initialize) do
15
18
  Rails.application.routes.append do
@@ -1,3 +1,3 @@
1
1
  module Rambulance
2
- VERSION = "0.6.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -8,6 +8,10 @@ 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
+
12
+ if Rails::VERSION::STRING >= "5.2"
13
+ config.action_controller.default_protect_from_forgery = true
14
+ end
11
15
  end
12
16
  Rails.backtrace_cleaner.remove_silencers!
13
17
  Rails.application.initialize!
@@ -15,7 +19,7 @@ Rails.application.initialize!
15
19
  # routes
16
20
  Rails.application.routes.draw do
17
21
  resources :users
18
- resources :projects, only: :index
22
+ resources :projects, only: [:index, :create]
19
23
  end
20
24
 
21
25
  # custom exception class
@@ -76,11 +80,16 @@ class UsersController < ApplicationController
76
80
  end
77
81
  end
78
82
  class ProjectsController < ApplicationController
83
+ if self.respond_to?(:skip_forgery_protection)
84
+ skip_forgery_protection
85
+ end
86
+
79
87
  if self.respond_to? :skip_before_action
80
- skip_before_action :bad_filter
88
+ skip_before_action :bad_filter, except: :create
81
89
  else
82
- skip_filter :bad_filter
90
+ skip_filter :bad_filter, except: :create
83
91
  end
84
92
 
85
93
  def index; end
94
+ def create; end
86
95
  end
@@ -29,6 +29,13 @@ 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
+
32
39
  private
33
40
 
34
41
  def without_layouts
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: 0.6.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Nishijima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-08 00:00:00.000000000 Z
11
+ date: 2019-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -148,6 +148,7 @@ files:
148
148
  - ".travis.yml"
149
149
  - Appraisals
150
150
  - CHANGELOG.md
151
+ - Dangerfile
151
152
  - Gemfile
152
153
  - LICENSE.txt
153
154
  - README.md
@@ -161,6 +162,7 @@ files:
161
162
  - gemfiles/rails_50.gemfile
162
163
  - gemfiles/rails_51.gemfile
163
164
  - gemfiles/rails_52.gemfile
165
+ - gemfiles/rails_60.gemfile
164
166
  - gemfiles/rails_edge.gemfile
165
167
  - lib/generators/rambulance/exceptions_app_generator.rb
166
168
  - lib/generators/rambulance/install_generator.rb
@@ -220,8 +222,7 @@ 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
+ rubygems_version: 3.0.3
225
226
  signing_key:
226
227
  specification_version: 4
227
228
  summary: Simple and safe way to dynamically generate error pages