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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c9a39129fbb4e1377d75be5b7267e7b0074c584
4
- data.tar.gz: 7ef274bdeee7522ae1e4d2e72efcd3c1f8c1ad3a
3
+ metadata.gz: 7ec9e246de4d4a482aec613131463383e11c6b65
4
+ data.tar.gz: f3c66bc4714c7fe4f2332d82b3504b310dfdf8a6
5
5
  SHA512:
6
- metadata.gz: f9b90b4730880cc22f36c7ff07225837d1d02a24cb1118f4306d27870905767a5ad93ec0ea1115b6eecb1410715a0a7a9435b5a7f7a67ee31e737e58cad867b1
7
- data.tar.gz: f1ad27c204dcb408bbb87086da228aac33db149da114e99216c9dd3ba7ddccb245131c84b37ec050a0478f4ceed07e5f567060f1802680ef6d920d6daa72ac1a
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
@@ -1,3 +1,3 @@
1
1
  module ActiveDecorator
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
@@ -0,0 +1 @@
1
+ <%= @book.error %>
@@ -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.0
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-21 00:00:00.000000000 Z
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: