rambulance 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +45 -12
  3. data/Appraisals +10 -2
  4. data/CHANGELOG.md +51 -0
  5. data/README.md +6 -11
  6. data/gemfiles/rails_32.gemfile +2 -2
  7. data/gemfiles/rails_40.gemfile +2 -2
  8. data/gemfiles/rails_41.gemfile +2 -2
  9. data/gemfiles/rails_42.gemfile +2 -2
  10. data/gemfiles/rails_50.gemfile +1 -1
  11. data/gemfiles/rails_51.gemfile +9 -0
  12. data/gemfiles/rails_edge.gemfile +3 -3
  13. data/lib/generators/rambulance/templates/exceptions_app.rb +4 -1
  14. data/lib/generators/rambulance/templates/views/bad_request.html.erb +1 -1
  15. data/lib/generators/rambulance/templates/views/forbidden.html.erb +1 -1
  16. data/lib/generators/rambulance/templates/views/internal_server_error.html.erb +1 -1
  17. data/lib/generators/rambulance/templates/views/not_found.html.erb +1 -1
  18. data/lib/generators/rambulance/templates/views/unprocessable_entity.html.erb +1 -1
  19. data/lib/rambulance/exceptions_app.rb +6 -0
  20. data/lib/rambulance/version.rb +1 -1
  21. data/rambulance.gemspec +1 -3
  22. data/test/fake_app/rails_app.rb +17 -12
  23. data/test/requests/error_page_test.rb +45 -0
  24. data/test/test_helper.rb +1 -0
  25. metadata +5 -14
  26. data/.rspec +0 -2
  27. data/lib/generators/rambulance/templates/views/bad_request.html.haml +0 -54
  28. data/lib/generators/rambulance/templates/views/bad_request.html.slim +0 -8
  29. data/lib/generators/rambulance/templates/views/forbidden.html.haml +0 -54
  30. data/lib/generators/rambulance/templates/views/forbidden.html.slim +0 -8
  31. data/lib/generators/rambulance/templates/views/internal_server_error.html.haml +0 -54
  32. data/lib/generators/rambulance/templates/views/internal_server_error.html.slim +0 -8
  33. data/lib/generators/rambulance/templates/views/not_found.html.haml +0 -55
  34. data/lib/generators/rambulance/templates/views/not_found.html.slim +0 -10
  35. data/lib/generators/rambulance/templates/views/unprocessable_entity.html.haml +0 -55
  36. data/lib/generators/rambulance/templates/views/unprocessable_entity.html.slim +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8652cd38fd09d82fef4cd8ef0d0c885aef91bc1
4
- data.tar.gz: 1df7d4a06a2818bc5ac865fc4bfe64e90add5d8e
3
+ metadata.gz: 41a24d609992f2ce07071bb783b231bbc358c66f
4
+ data.tar.gz: bee5f47a4df8ed67999da43b29652b613f7fab02
5
5
  SHA512:
6
- metadata.gz: 551b76ece9517a8b7c4c1495363a33a16419e3a449347d28bc5037fa342a62436e60ddce380a0d675f910e32b1915a01e215671ca76eaa86c1b45be9ac9c8035
7
- data.tar.gz: 9a8fec47fb990a7bfade1afffd719220e98dc826fc88382804d195f89a5c74687c017ab1596b311243055d9134026e1cf7a5a4dfdacbfb0e9964b72d9f0b1954
6
+ metadata.gz: 216306d2a9b1f76ececd7cf671823f8731f7f7bf4a99c90eb869b20b77fbc6e587d3a4806e3ab23610fe1ad66739d9fa6c06d2e2de80c4e7e34e72efd0bff3d0
7
+ data.tar.gz: c51fa8b131ab5fd77b00d73c7a6d85db0dc63bf8fe298643088b36714281d3e787bd1cc8085c798a0498b3ece725dfc35559435420dbca74e26bd97f839d661f
data/.travis.yml CHANGED
@@ -3,14 +3,19 @@ script: bundle exec rake
3
3
  cache: bundler
4
4
  sudo: false
5
5
 
6
+ before_install:
7
+ - gem update --system
8
+ - gem pristine bundler
9
+
6
10
  rvm:
7
- - 1.9.3
8
11
  - 2.0.0
9
12
  - 2.1
10
- - 2.2.5
11
- - 2.3.1
13
+ - 2.2.9
14
+ - 2.3.6
15
+ - 2.4.3
16
+ - 2.5.0
12
17
  - ruby-head
13
- - jruby
18
+ - jruby-9.1.15.0
14
19
  - jruby-head
15
20
 
16
21
  gemfile:
@@ -19,32 +24,60 @@ gemfile:
19
24
  - gemfiles/rails_41.gemfile
20
25
  - gemfiles/rails_42.gemfile
21
26
  - gemfiles/rails_50.gemfile
27
+ - gemfiles/rails_51.gemfile
22
28
  - gemfiles/rails_edge.gemfile
23
29
 
24
30
  matrix:
25
31
  exclude:
26
- - rvm: 1.9.3
27
- gemfile: gemfiles/rails_50.gemfile
28
- - rvm: 1.9.3
29
- gemfile: gemfiles/rails_edge.gemfile
30
32
  - rvm: 2.0.0
31
33
  gemfile: gemfiles/rails_50.gemfile
34
+ - rvm: 2.0.0
35
+ gemfile: gemfiles/rails_51.gemfile
32
36
  - rvm: 2.0.0
33
37
  gemfile: gemfiles/rails_edge.gemfile
34
38
  - rvm: 2.1
35
39
  gemfile: gemfiles/rails_50.gemfile
40
+ - rvm: 2.1
41
+ gemfile: gemfiles/rails_51.gemfile
36
42
  - rvm: 2.1
37
43
  gemfile: gemfiles/rails_edge.gemfile
38
- - rvm: 2.2.5
44
+ - rvm: 2.2.9
45
+ gemfile: gemfiles/rails_32.gemfile
46
+ - rvm: 2.3.6
47
+ gemfile: gemfiles/rails_32.gemfile
48
+ - rvm: 2.4.3
39
49
  gemfile: gemfiles/rails_32.gemfile
40
- - rvm: 2.3.1
50
+ - rvm: 2.4.3
51
+ gemfile: gemfiles/rails_40.gemfile
52
+ - rvm: 2.4.3
53
+ gemfile: gemfiles/rails_41.gemfile
54
+ - rvm: 2.5.0
41
55
  gemfile: gemfiles/rails_32.gemfile
56
+ - rvm: 2.5.0
57
+ gemfile: gemfiles/rails_40.gemfile
58
+ - rvm: 2.5.0
59
+ gemfile: gemfiles/rails_41.gemfile
42
60
  - rvm: ruby-head
43
61
  gemfile: gemfiles/rails_32.gemfile
62
+ - rvm: ruby-head
63
+ gemfile: gemfiles/rails_40.gemfile
64
+ - rvm: ruby-head
65
+ gemfile: gemfiles/rails_41.gemfile
66
+ - rvm: jruby-9.1.15.0
67
+ gemfile: gemfiles/rails_32.gemfile
68
+ - rvm: jruby-9.1.15.0
69
+ gemfile: gemfiles/rails_40.gemfile
70
+ - rvm: jruby-9.1.15.0
71
+ gemfile: gemfiles/rails_41.gemfile
72
+ - rvm: jruby-head
73
+ gemfile: gemfiles/rails_32.gemfile
74
+ - rvm: jruby-head
75
+ gemfile: gemfiles/rails_40.gemfile
76
+ - rvm: jruby-head
77
+ gemfile: gemfiles/rails_41.gemfile
44
78
  allow_failures:
45
79
  - rvm: ruby-head
46
- - rvm: jruby
80
+ - rvm: jruby-9.1.15.0
47
81
  - rvm: jruby-head
48
82
  - gemfile: gemfiles/rails_edge.gemfile
49
83
  - gemfile: gemfiles/rails_32.gem
50
- fast_finish: true
data/Appraisals CHANGED
@@ -3,6 +3,7 @@ appraise "rails_32" do
3
3
  gem "actionpack", "~> 3.2.0"
4
4
  gem "railties", "~> 3.2.0"
5
5
  gem "test-unit" if RUBY_VERSION >= "2.2.0"
6
+ gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
6
7
  end
7
8
 
8
9
  appraise "rails_40" do
@@ -10,30 +11,37 @@ appraise "rails_40" do
10
11
  gem "actionpack", "~> 4.0.0"
11
12
  gem "railties", "~> 4.0.0"
12
13
  gem "test-unit" if RUBY_VERSION >= "2.2.0"
14
+ gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
13
15
  end
14
16
 
15
17
  appraise "rails_41" do
16
18
  gem "activesupport", "~> 4.1.0"
17
19
  gem "actionpack", "~> 4.1.0"
18
20
  gem "railties", "~> 4.1.0"
21
+ gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
19
22
  end
20
23
 
21
24
  appraise "rails_42" do
22
25
  gem "activesupport", "~> 4.2.0"
23
26
  gem "actionpack", "~> 4.2.0"
24
27
  gem "railties", "~> 4.2.0"
25
-
26
28
  gem 'minitest', '~> 5.3.4'
29
+ gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
27
30
  end
28
31
 
29
32
  appraise "rails_50" do
30
33
  gem "activesupport", "~> 5.0.0"
31
34
  gem "actionpack", "~> 5.0.0"
32
35
  gem "railties", "~> 5.0.0"
33
-
34
36
  gem 'minitest', '~> 5.3.4'
35
37
  end
36
38
 
39
+ appraise "rails_51" do
40
+ gem "activesupport", "~> 5.1.0"
41
+ gem "actionpack", "~> 5.1.0"
42
+ gem "railties", "~> 5.1.0"
43
+ end
44
+
37
45
  appraise "rails_edge" do
38
46
  git 'git://github.com/rails/rails.git' do
39
47
  gem "activesupport", require: 'active_support'
data/CHANGELOG.md ADDED
@@ -0,0 +1,51 @@
1
+ ## [v0.4.0](https://github.com/yuki24/rambulance/tree/v0.4.0)
2
+
3
+ _<sup>released at 2016-10-12 02:25:55 UTC</sup>_
4
+
5
+ - Added support for Rails 5 and edge
6
+ - Added the ability to use helper methods in error templates([@willnet](https://github.com/willnet), [#37](https://github.com/yuki24/rambulance/pull/37))
7
+
8
+ ## [v0.3.1](https://github.com/yuki24/rambulance/tree/v0.3.1)
9
+
10
+ _<sup>released at 2015-05-18 01:53:59 UTC</sup>_
11
+
12
+ - Added slim support ([@liubin](https://github.com/liubin), [#20](https://github.com/yuki24/rambulance/pull/20))
13
+ - `rails g rambulance:install` no longer generates jbuilder templates if it's undefined
14
+ - The exceptions app no longer attempts to render layouts when the request format is json
15
+ - Now `rails g rambulance:install` always copies `application.html.erb` to `error.html.erb` again
16
+ - **incompatible change** : `error_layout` option for the install command has been removed in favor of the change above
17
+
18
+ ## [v0.3.0](https://github.com/yuki24/rambulance/tree/v0.3.0)
19
+
20
+ _<sup>released at 2015-01-23 13:42:35 UTC</sup>_
21
+
22
+ - Added 2 helper methods `#exception` and `#status_in_words` that you can use in views
23
+
24
+ ## [v0.2.0](https://github.com/yuki24/rambulance/tree/v0.2.0)
25
+
26
+ _<sup>released at 2014-09-18 03:38:18 UTC</sup>_
27
+
28
+ - Add support for Rails 4.2 beta
29
+ - Do not copy application.html.erb when `rails g rambulance:install` [[@kenn](https://github.com/kenn), [#5](https://github.com/yuki24/rambulance/issues/5)]
30
+ - Capture `ActionController::BadRequest` before processing action
31
+ - Dynamically generate exception/status mapping in initializer
32
+ - Add option to copy `application.html.erb` for error page layout
33
+
34
+ ## [v0.1.2](https://github.com/yuki24/rambulance/tree/v0.1.2)
35
+
36
+ _<sup>released at 2014-09-05 12:22:37 UTC</sup>_
37
+
38
+ - Fixed a bug where changing config.layout\_name doesn't actually switch layout [[@kenn](https://github.com/kenn), [#4](https://github.com/yuki24/rambulance/issues/4)]
39
+ - Exceptions app now refers to `app/views/#{config.view_path}` by default
40
+
41
+ ## [v0.1.1](https://github.com/yuki24/rambulance/tree/v0.1.1)
42
+
43
+ _<sup>released at 2014-06-22 02:39:06 UTC</sup>_
44
+
45
+ - Fixed a bug where installer command doesn't work
46
+
47
+ ## [v0.1.0](https://github.com/yuki24/rambulance/tree/v0.1.0)
48
+
49
+ _<sup>released at 2014-06-20 01:00:02 UTC</sup>_
50
+
51
+ - First release of rambulance!
data/README.md CHANGED
@@ -6,11 +6,11 @@ Rambulance provides a simple and safe way to dynamically render error pages for
6
6
 
7
7
  ### Simple and Safe
8
8
 
9
- Rambulance's exceptions app is simple, skinny and well-tested. It inherits `ActionController::Base`, so it works fine even if your `ApplicationController` has an issue.
9
+ Rambulance's exceptions app is simple, skinny and well-tested. It inherits from `ActionController::Base`, so it works fine even if your `ApplicationController` has an issue.
10
10
 
11
11
  ### Flexible
12
12
 
13
- You have full control of what error page to display 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 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.
14
14
 
15
15
  ### Easy installation and development
16
16
 
@@ -30,12 +30,7 @@ And then execute:
30
30
  $ rails g rambulance:install
31
31
  ```
32
32
 
33
- or specify the template engine by:
34
- ```
35
- $ rails g rambulance:install -e slim
36
- ```
37
-
38
- Rambulance now support `erb`, `haml`, `slim` template engines, if you don't specify the `-e` option, erb will be used as default.
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).
39
34
 
40
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)!
41
36
 
@@ -103,10 +98,10 @@ It'll generate your own custom exceptions app. You can use whatever techniques y
103
98
 
104
99
  ## Supported Versions
105
100
 
106
- * Ruby 1.9.3, 2.0.0, 2.1, 2.2, JRuby 1.7.19, JRuby head, Rubinius 2.4.1 and 2.5.3
107
- * Rails 3.2, 4.0, 4.1, 4.2 and edge
101
+ * Ruby 2.0.0, 2.1, 2.2, 2.3, JRuby 1.7.19, JRuby head, Rubinius 2.4.1 and 2.5.3
102
+ * Rails 3.2, 4.0, 4.1, 4.2, 5.0 and edge
108
103
 
109
- Rambulance doesn't work with Rails 3.1 and below since they don't provide any way to use a custom exceptions app.
104
+ Rambulance doesn't work with Rails 3.1 and below since they don't provide a way to use a custom exceptions app.
110
105
 
111
106
  ## Contributing
112
107
 
@@ -6,6 +6,6 @@ gem "activesupport", "~> 3.2.0"
6
6
  gem "actionpack", "~> 3.2.0"
7
7
  gem "railties", "~> 3.2.0"
8
8
  gem "test-unit" if RUBY_VERSION >= "2.2.0"
9
- gem "mime-types", "2.99.3" if RUBY_VERSION < "2.0.0"
9
+ gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
10
10
 
11
- gemspec :path => "../"
11
+ gemspec path: "../"
@@ -6,6 +6,6 @@ gem "activesupport", "~> 4.0.0"
6
6
  gem "actionpack", "~> 4.0.0"
7
7
  gem "railties", "~> 4.0.0"
8
8
  gem "test-unit" if RUBY_VERSION >= "2.2.0"
9
- gem "mime-types", "2.99.3" if RUBY_VERSION < "2.0.0"
9
+ gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
10
10
 
11
- gemspec :path => "../"
11
+ gemspec path: "../"
@@ -5,6 +5,6 @@ source "https://rubygems.org"
5
5
  gem "activesupport", "~> 4.1.0"
6
6
  gem "actionpack", "~> 4.1.0"
7
7
  gem "railties", "~> 4.1.0"
8
- gem "mime-types", "2.99.3" if RUBY_VERSION < "2.0.0"
8
+ gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
9
9
 
10
- gemspec :path => "../"
10
+ gemspec path: "../"
@@ -6,6 +6,6 @@ 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 "mime-types", "2.99.3" if RUBY_VERSION < "2.0.0"
9
+ gem 'nokogiri', '1.6.8.1' if RUBY_VERSION == "2.0.0"
10
10
 
11
- gemspec :path => "../"
11
+ gemspec path: "../"
@@ -7,4 +7,4 @@ gem "actionpack", "~> 5.0.0"
7
7
  gem "railties", "~> 5.0.0"
8
8
  gem "minitest", "~> 5.3.4"
9
9
 
10
- gemspec :path => "../"
10
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 5.1.0"
6
+ gem "actionpack", "~> 5.1.0"
7
+ gem "railties", "~> 5.1.0"
8
+
9
+ gemspec path: "../"
@@ -3,11 +3,11 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  git "git://github.com/rails/rails.git" do
6
- gem "activesupport", :require => "active_support"
7
- gem "actionpack", :require => "action_pack"
6
+ gem "activesupport", require: "active_support"
7
+ gem "actionpack", require: "action_pack"
8
8
  gem "railties"
9
9
  end
10
10
 
11
11
  gem "minitest", "~> 5.3.4"
12
12
 
13
- gemspec :path => "../"
13
+ gemspec path: "../"
@@ -5,9 +5,12 @@ class ExceptionsApp < Rambulance::ExceptionsApp
5
5
  def forbidden
6
6
  end
7
7
 
8
+ def internal_server_error
9
+ end
10
+
8
11
  def not_found
9
12
  end
10
13
 
11
- def internal_server_error
14
+ def unprocessable_entity
12
15
  end
13
16
  end
@@ -22,7 +22,7 @@
22
22
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
23
23
  }
24
24
 
25
- h1 {
25
+ div.dialog h1 {
26
26
  font-size: 100%;
27
27
  color: #730E15;
28
28
  line-height: 1.5em;
@@ -22,7 +22,7 @@
22
22
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
23
23
  }
24
24
 
25
- h1 {
25
+ div.dialog h1 {
26
26
  font-size: 100%;
27
27
  color: #730E15;
28
28
  line-height: 1.5em;
@@ -22,7 +22,7 @@
22
22
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
23
23
  }
24
24
 
25
- h1 {
25
+ div.dialog h1 {
26
26
  font-size: 100%;
27
27
  color: #730E15;
28
28
  line-height: 1.5em;
@@ -22,7 +22,7 @@
22
22
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
23
23
  }
24
24
 
25
- h1 {
25
+ div.dialog h1 {
26
26
  font-size: 100%;
27
27
  color: #730E15;
28
28
  line-height: 1.5em;
@@ -22,7 +22,7 @@
22
22
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
23
23
  }
24
24
 
25
- h1 {
25
+ div.dialog h1 {
26
26
  font-size: 100%;
27
27
  color: #730E15;
28
28
  line-height: 1.5em;
@@ -60,6 +60,12 @@ module Rambulance
60
60
  request.env["MALFORMED_QUERY_STRING"], request.env["QUERY_STRING"] = request.env["QUERY_STRING"], ""
61
61
  end
62
62
 
63
+ begin
64
+ request.POST
65
+ rescue BAD_REQUEST_EXCEPTION, ArgumentError
66
+ request.env["MALFORMED_BODY"], request.env["rack.input"] = request.env["rack.input"], StringIO.new
67
+ end
68
+
63
69
  super
64
70
  end
65
71
 
@@ -1,3 +1,3 @@
1
1
  module Rambulance
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/rambulance.gemspec CHANGED
@@ -12,10 +12,8 @@ Gem::Specification.new do |spec|
12
12
  spec.description = %q{Rambulance provides a simple and safe way to dynamically generate error pages.}
13
13
  spec.homepage = "http://github.com/yuki24/rambulance"
14
14
  spec.license = "MIT"
15
-
16
15
  spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.test_files = spec.files.grep(%r{^test/})
19
17
  spec.require_paths = ["lib"]
20
18
 
21
19
  spec.add_dependency "activesupport"
@@ -1,20 +1,19 @@
1
1
  require 'jbuilder'
2
2
 
3
3
  # config
4
- app = Class.new(Rails::Application)
5
- app.config.secret_token = '964ab2f0fbbb68bc36f3cc487ca296bb8555fac50627924024c245a1599e5265'
6
- app.config.session_store :cookie_store, :key => '_myapp_session'
7
- app.config.active_support.deprecation = :log
8
- app.config.eager_load = false
9
-
10
- # Rais.root
11
- app.config.root = File.dirname(__FILE__)
12
- app.config.autoload_paths += ["#{app.config.root}/lib"] if ENV["CUSTOM_EXCEPTIONS_APP"]
4
+ class TestApp < Rails::Application
5
+ config.secret_token = '964ab2f0fbbb68bc36f3cc487ca296bb8555fac50627924024c245a1599e5265'
6
+ config.session_store :cookie_store, :key => '_myapp_session'
7
+ config.active_support.deprecation = :log
8
+ config.eager_load = false
9
+ config.root = File.dirname(__FILE__)
10
+ config.autoload_paths += ["#{config.root}/lib"] if ENV["CUSTOM_EXCEPTIONS_APP"]
11
+ end
13
12
  Rails.backtrace_cleaner.remove_silencers!
14
- app.initialize!
13
+ Rails.application.initialize!
15
14
 
16
15
  # routes
17
- app.routes.draw do
16
+ Rails.application.routes.draw do
18
17
  resources :users
19
18
  end
20
19
 
@@ -63,7 +62,13 @@ class UsersController < ApplicationController
63
62
  raise ActionController::InvalidAuthenticityToken
64
63
  end
65
64
 
66
- def create; end
65
+ def create
66
+ render text: 'created.', status: 201
67
+ end
68
+
69
+ def update
70
+ render text: 'updated.', status: 201
71
+ end
67
72
 
68
73
  def edit
69
74
  raise ForbiddenException
@@ -41,6 +41,51 @@ class ErrorPageTest < ActionDispatch::IntegrationTest
41
41
  assert_includes page.body, "Page not found."
42
42
  end
43
43
 
44
+ if Rails.version < '4.2.0'
45
+ # Versions eariler than 4.2 use `Rack::MethodOverride` that calls the
46
+ # request#POST method. It is configured to be called before the request
47
+ # reaches Rails' ShowException, and it's impossible to capture from it.
48
+ #
49
+ # Since there is no good solution for us to fix it, I will consider it
50
+ # to be a "won't fix" edge case and leave a test case here.
51
+ test 'raises ArgumentError when posting malformed body' do
52
+ assert_raises ArgumentError do
53
+ page.driver.post '/users', 'email=abcd%%72900'
54
+ end
55
+ end
56
+ elsif Rails.version.start_with?('4.2')
57
+ test 'displays the 201 page' do
58
+ page.driver.post '/users', 'email=abcd%%72900'
59
+
60
+ assert_equal 201, page.status_code
61
+ assert_includes page.body, "created."
62
+ end
63
+ else
64
+ test 'displays the 400 page for POST request with malformed body' do
65
+ page.driver.post '/users', 'email=abcd%%72900'
66
+
67
+ assert_equal 400, page.status_code
68
+ assert_includes page.body, "Error page"
69
+ assert_includes page.body, "Bad request."
70
+ end
71
+
72
+ test 'displays the 400 page for PUT request with malformed body' do
73
+ page.driver.put '/users/1', 'email=abcd%%72900'
74
+
75
+ assert_equal 400, page.status_code
76
+ assert_includes page.body, "Error page"
77
+ assert_includes page.body, "Bad request."
78
+ end
79
+
80
+ test 'displays the 404 page for request to non-existing page with malformed body' do
81
+ page.driver.post '/doesnt_exist', 'email=abcd%%72900'
82
+
83
+ assert_equal 404, page.status_code
84
+ assert_includes page.body, "Error page"
85
+ assert_includes page.body, "Page not found."
86
+ end
87
+ end
88
+
44
89
  test 'displays the 403 page for ForbiddenException' do
45
90
  visit '/users/1/edit'
46
91
 
data/test/test_helper.rb CHANGED
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
 
4
4
  require 'rails'
5
5
  require 'minitest/autorun'
6
+ require 'minitest/pride'
6
7
  require 'action_controller/railtie'
7
8
  require 'action_view/railtie'
8
9
  require 'bundler/setup'
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.4.0
4
+ version: 0.5.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: 2016-10-12 00:00:00.000000000 Z
11
+ date: 2018-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -145,9 +145,9 @@ extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
147
  - ".gitignore"
148
- - ".rspec"
149
148
  - ".travis.yml"
150
149
  - Appraisals
150
+ - CHANGELOG.md
151
151
  - Gemfile
152
152
  - LICENSE.txt
153
153
  - README.md
@@ -157,30 +157,21 @@ files:
157
157
  - gemfiles/rails_41.gemfile
158
158
  - gemfiles/rails_42.gemfile
159
159
  - gemfiles/rails_50.gemfile
160
+ - gemfiles/rails_51.gemfile
160
161
  - gemfiles/rails_edge.gemfile
161
162
  - lib/generators/rambulance/exceptions_app_generator.rb
162
163
  - lib/generators/rambulance/install_generator.rb
163
164
  - lib/generators/rambulance/templates/exceptions_app.rb
164
165
  - lib/generators/rambulance/templates/rambulance.rb
165
166
  - lib/generators/rambulance/templates/views/bad_request.html.erb
166
- - lib/generators/rambulance/templates/views/bad_request.html.haml
167
- - lib/generators/rambulance/templates/views/bad_request.html.slim
168
167
  - lib/generators/rambulance/templates/views/bad_request.json.jbuilder
169
168
  - lib/generators/rambulance/templates/views/forbidden.html.erb
170
- - lib/generators/rambulance/templates/views/forbidden.html.haml
171
- - lib/generators/rambulance/templates/views/forbidden.html.slim
172
169
  - lib/generators/rambulance/templates/views/forbidden.json.jbuilder
173
170
  - lib/generators/rambulance/templates/views/internal_server_error.html.erb
174
- - lib/generators/rambulance/templates/views/internal_server_error.html.haml
175
- - lib/generators/rambulance/templates/views/internal_server_error.html.slim
176
171
  - lib/generators/rambulance/templates/views/internal_server_error.json.jbuilder
177
172
  - lib/generators/rambulance/templates/views/not_found.html.erb
178
- - lib/generators/rambulance/templates/views/not_found.html.haml
179
- - lib/generators/rambulance/templates/views/not_found.html.slim
180
173
  - lib/generators/rambulance/templates/views/not_found.json.jbuilder
181
174
  - lib/generators/rambulance/templates/views/unprocessable_entity.html.erb
182
- - lib/generators/rambulance/templates/views/unprocessable_entity.html.haml
183
- - lib/generators/rambulance/templates/views/unprocessable_entity.html.slim
184
175
  - lib/generators/rambulance/templates/views/unprocessable_entity.json.jbuilder
185
176
  - lib/rambulance.rb
186
177
  - lib/rambulance/exceptions_app.rb
@@ -221,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
212
  version: '0'
222
213
  requirements: []
223
214
  rubyforge_project:
224
- rubygems_version: 2.5.1
215
+ rubygems_version: 2.6.14
225
216
  signing_key:
226
217
  specification_version: 4
227
218
  summary: Simple and safe way to dynamically generate error pages
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --colour
2
- --format=d
@@ -1,54 +0,0 @@
1
- :css
2
- div.dialog {
3
- color: #2E2F30;
4
- text-align: center;
5
- font-family: arial, sans-serif;
6
- margin: 0;
7
- width: 95%;
8
- max-width: 33em;
9
- margin: 4em auto;
10
- }
11
-
12
- div.dialog > div {
13
- border: 1px solid #CCC;
14
- border-right-color: #999;
15
- border-left-color: #999;
16
- border-bottom-color: #BBB;
17
- border-top: #B00100 solid 4px;
18
- border-top-left-radius: 9px;
19
- border-top-right-radius: 9px;
20
- background-color: white;
21
- padding: 7px 12% 0;
22
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
23
- }
24
-
25
- h1 {
26
- font-size: 100%;
27
- color: #730E15;
28
- line-height: 1.5em;
29
- margin: 10px 0;
30
- }
31
-
32
- div.dialog p {
33
- margin: 16px 0;
34
- }
35
-
36
- div.dialog > p {
37
- margin: 0 0 1em;
38
- padding: 1em;
39
- background-color: #F7F7F7;
40
- border: 1px solid #CCC;
41
- border-right-color: #999;
42
- border-left-color: #999;
43
- border-bottom-color: #999;
44
- border-bottom-left-radius: 4px;
45
- border-bottom-right-radius: 4px;
46
- border-top-color: #DADADA;
47
- color: #666;
48
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
- }
50
- / This file lives in app/views/errors/bad_request.html.erb
51
- .dialog
52
- %div
53
- %h1 Bad request
54
- %p The service received a incomplete request.
@@ -1,8 +0,0 @@
1
- style
2
- | div.dialog { color: #2E2F30; text-align: center; font-family: arial, sans-serif; margin: 0; width: 95%; max-width: 33em; margin: 4em auto; } div.dialog > div { border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; border-bottom-color: #BBB; border-top: #B00100 solid 4px; border-top-left-radius: 9px; border-top-right-radius: 9px; background-color: white; padding: 7px 12% 0; box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); } h1 { font-size: 100%; color: #730E15; line-height: 1.5em; margin: 10px 0; } div.dialog p { margin: 16px 0; } div.dialog > p { margin: 0 0 1em; padding: 1em; background-color: #F7F7F7; border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; border-bottom-color: #999; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-color: #DADADA; color: #666; box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); }
3
- .dialog
4
- div
5
- h1
6
- | Bad request
7
- p
8
- | The service received a incomplete request.
@@ -1,54 +0,0 @@
1
- :css
2
- div.dialog {
3
- color: #2E2F30;
4
- text-align: center;
5
- font-family: arial, sans-serif;
6
- margin: 0;
7
- width: 95%;
8
- max-width: 33em;
9
- margin: 4em auto;
10
- }
11
-
12
- div.dialog > div {
13
- border: 1px solid #CCC;
14
- border-right-color: #999;
15
- border-left-color: #999;
16
- border-bottom-color: #BBB;
17
- border-top: #B00100 solid 4px;
18
- border-top-left-radius: 9px;
19
- border-top-right-radius: 9px;
20
- background-color: white;
21
- padding: 7px 12% 0;
22
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
23
- }
24
-
25
- h1 {
26
- font-size: 100%;
27
- color: #730E15;
28
- line-height: 1.5em;
29
- margin: 10px 0;
30
- }
31
-
32
- div.dialog p {
33
- margin: 16px 0;
34
- }
35
-
36
- div.dialog > p {
37
- margin: 0 0 1em;
38
- padding: 1em;
39
- background-color: #F7F7F7;
40
- border: 1px solid #CCC;
41
- border-right-color: #999;
42
- border-left-color: #999;
43
- border-bottom-color: #999;
44
- border-bottom-left-radius: 4px;
45
- border-bottom-right-radius: 4px;
46
- border-top-color: #DADADA;
47
- color: #666;
48
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
- }
50
- / This file lives in app/views/errors/forbidden.html.erb
51
- .dialog
52
- %div
53
- %h1 Forbidden.
54
- %p You are not authorized to access this page.
@@ -1,8 +0,0 @@
1
- style
2
- | div.dialog { color: #2E2F30; text-align: center; font-family: arial, sans-serif; margin: 0; width: 95%; max-width: 33em; margin: 4em auto; } div.dialog > div { border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; border-bottom-color: #BBB; border-top: #B00100 solid 4px; border-top-left-radius: 9px; border-top-right-radius: 9px; background-color: white; padding: 7px 12% 0; box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); } h1 { font-size: 100%; color: #730E15; line-height: 1.5em; margin: 10px 0; } div.dialog p { margin: 16px 0; } div.dialog > p { margin: 0 0 1em; padding: 1em; background-color: #F7F7F7; border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; border-bottom-color: #999; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-color: #DADADA; color: #666; box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); }
3
- .dialog
4
- div
5
- h1
6
- | Forbidden.
7
- p
8
- | You are not authorized to access this page.
@@ -1,54 +0,0 @@
1
- :css
2
- div.dialog {
3
- color: #2E2F30;
4
- text-align: center;
5
- font-family: arial, sans-serif;
6
- margin: 0;
7
- width: 95%;
8
- max-width: 33em;
9
- margin: 4em auto;
10
- }
11
-
12
- div.dialog > div {
13
- border: 1px solid #CCC;
14
- border-right-color: #999;
15
- border-left-color: #999;
16
- border-bottom-color: #BBB;
17
- border-top: #B00100 solid 4px;
18
- border-top-left-radius: 9px;
19
- border-top-right-radius: 9px;
20
- background-color: white;
21
- padding: 7px 12% 0;
22
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
23
- }
24
-
25
- h1 {
26
- font-size: 100%;
27
- color: #730E15;
28
- line-height: 1.5em;
29
- margin: 10px 0;
30
- }
31
-
32
- div.dialog p {
33
- margin: 16px 0;
34
- }
35
-
36
- div.dialog > p {
37
- margin: 0 0 1em;
38
- padding: 1em;
39
- background-color: #F7F7F7;
40
- border: 1px solid #CCC;
41
- border-right-color: #999;
42
- border-left-color: #999;
43
- border-bottom-color: #999;
44
- border-bottom-left-radius: 4px;
45
- border-bottom-right-radius: 4px;
46
- border-top-color: #DADADA;
47
- color: #666;
48
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
- }
50
- / This file lives in app/views/errors/internal_server_error.html.erb
51
- .dialog
52
- %div
53
- %h1 We're sorry, but something went wrong.
54
- %p If you are the application owner check the logs for more information.
@@ -1,8 +0,0 @@
1
- style
2
- | div.dialog { color: #2E2F30; text-align: center; font-family: arial, sans-serif; margin: 0; width: 95%; max-width: 33em; margin: 4em auto; } div.dialog > div { border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; border-bottom-color: #BBB; border-top: #B00100 solid 4px; border-top-left-radius: 9px; border-top-right-radius: 9px; background-color: white; padding: 7px 12% 0; box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); } h1 { font-size: 100%; color: #730E15; line-height: 1.5em; margin: 10px 0; } div.dialog p { margin: 16px 0; } div.dialog > p { margin: 0 0 1em; padding: 1em; background-color: #F7F7F7; border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; border-bottom-color: #999; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-color: #DADADA; color: #666; box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); }
3
- .dialog
4
- div
5
- h1
6
- | We're sorry, but something went wrong.
7
- p
8
- | If you are the application owner check the logs for more information.
@@ -1,55 +0,0 @@
1
- :css
2
- div.dialog {
3
- color: #2E2F30;
4
- text-align: center;
5
- font-family: arial, sans-serif;
6
- margin: 0;
7
- width: 95%;
8
- max-width: 33em;
9
- margin: 4em auto;
10
- }
11
-
12
- div.dialog > div {
13
- border: 1px solid #CCC;
14
- border-right-color: #999;
15
- border-left-color: #999;
16
- border-bottom-color: #BBB;
17
- border-top: #B00100 solid 4px;
18
- border-top-left-radius: 9px;
19
- border-top-right-radius: 9px;
20
- background-color: white;
21
- padding: 7px 12% 0;
22
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
23
- }
24
-
25
- h1 {
26
- font-size: 100%;
27
- color: #730E15;
28
- line-height: 1.5em;
29
- margin: 10px 0;
30
- }
31
-
32
- div.dialog p {
33
- margin: 16px 0;
34
- }
35
-
36
- div.dialog > p {
37
- margin: 0 0 1em;
38
- padding: 1em;
39
- background-color: #F7F7F7;
40
- border: 1px solid #CCC;
41
- border-right-color: #999;
42
- border-left-color: #999;
43
- border-bottom-color: #999;
44
- border-bottom-left-radius: 4px;
45
- border-bottom-right-radius: 4px;
46
- border-top-color: #DADADA;
47
- color: #666;
48
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
- }
50
- / This file lives in app/views/errors/not_found.html.erb
51
- .dialog
52
- %div
53
- %h1 The page you were looking for doesn't exist.
54
- %p You may have mistyped the address or the page may have moved.
55
- %p If you are the application owner check the logs for more information.
@@ -1,10 +0,0 @@
1
- style
2
- | div.dialog { color: #2E2F30; text-align: center; font-family: arial, sans-serif; margin: 0; width: 95%; max-width: 33em; margin: 4em auto; } div.dialog > div { border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; border-bottom-color: #BBB; border-top: #B00100 solid 4px; border-top-left-radius: 9px; border-top-right-radius: 9px; background-color: white; padding: 7px 12% 0; box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); } h1 { font-size: 100%; color: #730E15; line-height: 1.5em; margin: 10px 0; } div.dialog p { margin: 16px 0; } div.dialog > p { margin: 0 0 1em; padding: 1em; background-color: #F7F7F7; border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; border-bottom-color: #999; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-color: #DADADA; color: #666; box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); }
3
- .dialog
4
- div
5
- h1
6
- | The page you were looking for doesn't exist.
7
- p
8
- | You may have mistyped the address or the page may have moved.
9
- p
10
- | If you are the application owner check the logs for more information.
@@ -1,55 +0,0 @@
1
- :css
2
- div.dialog {
3
- color: #2E2F30;
4
- text-align: center;
5
- font-family: arial, sans-serif;
6
- margin: 0;
7
- width: 95%;
8
- max-width: 33em;
9
- margin: 4em auto;
10
- }
11
-
12
- div.dialog > div {
13
- border: 1px solid #CCC;
14
- border-right-color: #999;
15
- border-left-color: #999;
16
- border-bottom-color: #BBB;
17
- border-top: #B00100 solid 4px;
18
- border-top-left-radius: 9px;
19
- border-top-right-radius: 9px;
20
- background-color: white;
21
- padding: 7px 12% 0;
22
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
23
- }
24
-
25
- h1 {
26
- font-size: 100%;
27
- color: #730E15;
28
- line-height: 1.5em;
29
- margin: 10px 0;
30
- }
31
-
32
- div.dialog p {
33
- margin: 16px 0;
34
- }
35
-
36
- div.dialog > p {
37
- margin: 0 0 1em;
38
- padding: 1em;
39
- background-color: #F7F7F7;
40
- border: 1px solid #CCC;
41
- border-right-color: #999;
42
- border-left-color: #999;
43
- border-bottom-color: #999;
44
- border-bottom-left-radius: 4px;
45
- border-bottom-right-radius: 4px;
46
- border-top-color: #DADADA;
47
- color: #666;
48
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
- }
50
- / This file lives in app/views/errors/unprocessable_entity.html.erb
51
- .dialog
52
- %div
53
- %h1 The change you wanted was rejected.
54
- %p Maybe you tried to change something you didn't have access to.
55
- %p If you are the application owner check the logs for more information.
@@ -1,10 +0,0 @@
1
- style
2
- | div.dialog { color: #2E2F30; text-align: center; font-family: arial, sans-serif; margin: 0; width: 95%; max-width: 33em; margin: 4em auto; } div.dialog > div { border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; border-bottom-color: #BBB; border-top: #B00100 solid 4px; border-top-left-radius: 9px; border-top-right-radius: 9px; background-color: white; padding: 7px 12% 0; box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); } h1 { font-size: 100%; color: #730E15; line-height: 1.5em; margin: 10px 0; } div.dialog p { margin: 16px 0; } div.dialog > p { margin: 0 0 1em; padding: 1em; background-color: #F7F7F7; border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; border-bottom-color: #999; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-color: #DADADA; color: #666; box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); }
3
- .dialog
4
- div
5
- h1
6
- | The change you wanted was rejected.
7
- p
8
- | Maybe you tried to change something you didn't have access to.
9
- p
10
- | If you are the application owner check the logs for more information.