rambulance 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rambulance.rb +2 -2
- data/lib/rambulance/exceptions_app.rb +10 -2
- data/lib/rambulance/version.rb +1 -1
- data/spec/fake_app/app/views/layouts/application.html.erb +10 -0
- data/spec/fake_app/lib/exceptions_app.rb +2 -0
- data/spec/requests/error_page_spec.rb +20 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 146d016881be5aa21f7d33de3bab927491c06160
|
4
|
+
data.tar.gz: d0ef5bc64965f81c3834865772875b399161a074
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9459c8e769ae84353aac43085acb710c64fb94f469fe28530fe0797988592ae38eff50f3512e0ad15b36c300940013e441eed8c1f000cc714a046d52a887dfa
|
7
|
+
data.tar.gz: 0761811510d0c91d4efc7c6c4446dc2bd6e71f95a2f7876d046ec034a4d4ee052148a6ae4ce13f28b688c5ce278da3c75f65a5d666acb5f17338118d90146210
|
data/lib/rambulance.rb
CHANGED
@@ -3,11 +3,11 @@ require "rambulance/railtie"
|
|
3
3
|
|
4
4
|
module Rambulance
|
5
5
|
|
6
|
-
# List of custom pairs of
|
6
|
+
# List of custom pairs of exception/corresponding http status.
|
7
7
|
mattr_reader :rescue_responses
|
8
8
|
@@rescue_responses = {}
|
9
9
|
|
10
|
-
# The
|
10
|
+
# The name of the layout file for the error pages.
|
11
11
|
mattr_accessor :layout_name
|
12
12
|
@@layout_name = "error"
|
13
13
|
|
@@ -8,7 +8,7 @@ module Rambulance
|
|
8
8
|
end.invert
|
9
9
|
|
10
10
|
class ExceptionsApp < ActionController::Base
|
11
|
-
layout
|
11
|
+
layout :layout_name
|
12
12
|
|
13
13
|
def self.call(env)
|
14
14
|
exception = env["action_dispatch.exception"]
|
@@ -50,7 +50,15 @@ module Rambulance
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def error_path(status_in_words = status_in_words())
|
53
|
-
"#{
|
53
|
+
"#{controller_path}/#{status_in_words}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def layout_name
|
57
|
+
Rambulance.layout_name
|
58
|
+
end
|
59
|
+
|
60
|
+
def controller_path
|
61
|
+
Rambulance.view_path
|
54
62
|
end
|
55
63
|
end
|
56
64
|
end
|
data/lib/rambulance/version.rb
CHANGED
@@ -38,11 +38,31 @@ feature 'Error pages' do
|
|
38
38
|
page.body.should have_content "Error page"
|
39
39
|
page.body.should have_content "Page not found."
|
40
40
|
end
|
41
|
+
|
42
|
+
context "with a custom layout name" do
|
43
|
+
before do
|
44
|
+
@org, Rambulance.layout_name = Rambulance.layout_name, "application"
|
45
|
+
end
|
46
|
+
after { Rambulance.layout_name = @org }
|
47
|
+
|
48
|
+
scenario 'uses the custom layout' do
|
49
|
+
visit '/doesnt_exist'
|
50
|
+
page.body.should have_content "Application page"
|
51
|
+
end
|
52
|
+
end
|
41
53
|
end
|
42
54
|
|
43
55
|
context "With a custom exception app", if: ENV["CUSTOM_EXCEPTIONS_APP"] do
|
44
56
|
it_behaves_like "an action that renders 500 page if the template is missing"
|
45
57
|
|
58
|
+
scenario 'Not found due to ActinoController::RoutingError' do
|
59
|
+
visit '/doesnt_exist'
|
60
|
+
|
61
|
+
page.status_code.should == 404
|
62
|
+
page.body.should have_content "Error page"
|
63
|
+
page.body.should have_content "Page not found."
|
64
|
+
end
|
65
|
+
|
46
66
|
scenario 'Internal server error due to RuntimeError' do
|
47
67
|
visit '/users/1'
|
48
68
|
|
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuki Nishijima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -212,6 +212,7 @@ files:
|
|
212
212
|
- spec/fake_app/app/views/errors/internal_server_error.json.jbuilder
|
213
213
|
- spec/fake_app/app/views/errors/not_found.html.erb
|
214
214
|
- spec/fake_app/app/views/errors/not_found.json.jbuilder
|
215
|
+
- spec/fake_app/app/views/layouts/application.html.erb
|
215
216
|
- spec/fake_app/app/views/layouts/error.html.erb
|
216
217
|
- spec/fake_app/lib/exceptions_app.rb
|
217
218
|
- spec/fake_app/rails_app.rb
|
@@ -247,6 +248,7 @@ test_files:
|
|
247
248
|
- spec/fake_app/app/views/errors/internal_server_error.json.jbuilder
|
248
249
|
- spec/fake_app/app/views/errors/not_found.html.erb
|
249
250
|
- spec/fake_app/app/views/errors/not_found.json.jbuilder
|
251
|
+
- spec/fake_app/app/views/layouts/application.html.erb
|
250
252
|
- spec/fake_app/app/views/layouts/error.html.erb
|
251
253
|
- spec/fake_app/lib/exceptions_app.rb
|
252
254
|
- spec/fake_app/rails_app.rb
|