active_decorator 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_decorator/monkey/action_controller/base/rescue_from.rb +11 -0
- data/lib/active_decorator/railtie.rb +1 -0
- data/lib/active_decorator/version.rb +1 -1
- data/spec/fake_app/app/views/books/error.html.erb +1 -0
- data/spec/fake_app/fake_app.rb +16 -0
- data/spec/features/action_view_helpers_spec.rb +5 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ec9e246de4d4a482aec613131463383e11c6b65
|
4
|
+
data.tar.gz: f3c66bc4714c7fe4f2332d82b3504b310dfdf8a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1a8711efe0ae4efe92b48a362f7a3d39d79ff734d16fa587817a7d53056aeafae90281669572a872b25f97464c4835d781fd5ba70e1c473868b224218048ffc
|
7
|
+
data.tar.gz: 803072777c134ff503868e0f7909f866ddd87fad2e58151fcc65522d5a91e9372d543db71f496b7d2bf6117cd32279866013d47643ba3b9ac4a1decf67730bbc
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ActionController
|
2
|
+
class Base
|
3
|
+
def rescue_with_handler_with_decorator_view_context(exception)
|
4
|
+
ActiveDecorator::ViewContext.push(view_context)
|
5
|
+
rescue_with_handler_without_decorator_view_context(exception)
|
6
|
+
ensure
|
7
|
+
ActiveDecorator::ViewContext.pop
|
8
|
+
end
|
9
|
+
alias_method_chain :rescue_with_handler, :decorator_view_context
|
10
|
+
end
|
11
|
+
end
|
@@ -9,6 +9,7 @@ module ActiveDecorator
|
|
9
9
|
end
|
10
10
|
ActiveSupport.on_load(:action_controller) do
|
11
11
|
require 'active_decorator/monkey/abstract_controller/rendering'
|
12
|
+
require 'active_decorator/monkey/action_controller/base/rescue_from'
|
12
13
|
ActionController::Base.send :include, ActiveDecorator::ViewContext::Filter
|
13
14
|
end
|
14
15
|
ActiveSupport.on_load(:action_mailer) do
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @book.error %>
|
data/spec/fake_app/fake_app.rb
CHANGED
@@ -26,6 +26,7 @@ ActiveDecoratorTestApp::Application.routes.draw do
|
|
26
26
|
resources :authors, :only => [:index, :show] do
|
27
27
|
resources :books, :only => [:index, :show] do
|
28
28
|
member do
|
29
|
+
get :error
|
29
30
|
post :purchase
|
30
31
|
end
|
31
32
|
end
|
@@ -72,6 +73,10 @@ module BookDecorator
|
|
72
73
|
def cover_image
|
73
74
|
image_tag 'cover.png'
|
74
75
|
end
|
76
|
+
|
77
|
+
def error
|
78
|
+
"ERROR"
|
79
|
+
end
|
75
80
|
end
|
76
81
|
|
77
82
|
# decorator fake
|
@@ -105,6 +110,12 @@ class AuthorsController < ApplicationController
|
|
105
110
|
end
|
106
111
|
end
|
107
112
|
class BooksController < ApplicationController
|
113
|
+
class CustomError < StandardError; end
|
114
|
+
|
115
|
+
rescue_from CustomError do
|
116
|
+
render "error"
|
117
|
+
end
|
118
|
+
|
108
119
|
def index
|
109
120
|
@author = Author.find params[:author_id]
|
110
121
|
@books = @author.books
|
@@ -114,6 +125,11 @@ class BooksController < ApplicationController
|
|
114
125
|
@book = Author.find(params[:author_id]).books.find(params[:id])
|
115
126
|
end
|
116
127
|
|
128
|
+
def error
|
129
|
+
@book = Author.find(params[:author_id]).books.find(params[:id])
|
130
|
+
raise CustomError, "error"
|
131
|
+
end
|
132
|
+
|
117
133
|
def purchase
|
118
134
|
@book = Author.find(params[:author_id]).books.find(params[:id])
|
119
135
|
|
@@ -14,6 +14,11 @@ feature 'fallback to helpers' do
|
|
14
14
|
page.should have_css('img')
|
15
15
|
end
|
16
16
|
|
17
|
+
scenario 'invoking action_view helper methods in rescue_from view' do
|
18
|
+
visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}/error"
|
19
|
+
page.should have_content('ERROR')
|
20
|
+
end
|
21
|
+
|
17
22
|
scenario 'make sure that action_view + action_mailer works' do
|
18
23
|
visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}"
|
19
24
|
click_link 'purchase'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_decorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple and Rubyish view helper for Rails 3
|
14
14
|
email:
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- lib/active_decorator/decorator.rb
|
37
37
|
- lib/active_decorator/helpers.rb
|
38
38
|
- lib/active_decorator/monkey/abstract_controller/rendering.rb
|
39
|
+
- lib/active_decorator/monkey/action_controller/base/rescue_from.rb
|
39
40
|
- lib/active_decorator/monkey/action_view/partial_renderer.rb
|
40
41
|
- lib/active_decorator/railtie.rb
|
41
42
|
- lib/active_decorator/version.rb
|
@@ -55,6 +56,7 @@ files:
|
|
55
56
|
- spec/fake_app/app/views/books/_book.html.erb
|
56
57
|
- spec/fake_app/app/views/books/_book.json.jbuilder
|
57
58
|
- spec/fake_app/app/views/books/_book_locals.html.erb
|
59
|
+
- spec/fake_app/app/views/books/error.html.erb
|
58
60
|
- spec/fake_app/app/views/books/index.html.erb
|
59
61
|
- spec/fake_app/app/views/books/purchase.html.erb
|
60
62
|
- spec/fake_app/app/views/books/show.html.erb
|
@@ -98,6 +100,7 @@ test_files:
|
|
98
100
|
- spec/fake_app/app/views/books/_book.html.erb
|
99
101
|
- spec/fake_app/app/views/books/_book.json.jbuilder
|
100
102
|
- spec/fake_app/app/views/books/_book_locals.html.erb
|
103
|
+
- spec/fake_app/app/views/books/error.html.erb
|
101
104
|
- spec/fake_app/app/views/books/index.html.erb
|
102
105
|
- spec/fake_app/app/views/books/purchase.html.erb
|
103
106
|
- spec/fake_app/app/views/books/show.html.erb
|
@@ -108,4 +111,3 @@ test_files:
|
|
108
111
|
- spec/features/jbuilder_spec.rb
|
109
112
|
- spec/features/partial_spec.rb
|
110
113
|
- spec/spec_helper.rb
|
111
|
-
has_rdoc:
|