flail 0.1.6 → 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 +7 -0
- data/.gitignore +7 -2
- data/.ruby-version +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -3
- data/README.md +4 -17
- data/lib/flail.rb +2 -1
- data/lib/flail/{rack.rb → rack_middleware_exception_hook.rb} +1 -1
- data/lib/flail/rails/controller_methods.rb +16 -0
- data/lib/flail/railtie.rb +8 -1
- data/lib/flail/version.rb +1 -1
- data/spec/exception_spec.rb +9 -6
- data/spec/{rack_spec.rb → rack_middleware_exception_hook_spec.rb} +3 -3
- data/spec/spec_helper.rb +0 -5
- metadata +32 -57
- data/.rvmrc +0 -1
- data/lib/flail/rails.rb +0 -16
- data/lib/flail/rails/rescue_action.rb +0 -24
- data/rails/init.rb +0 -1
- data/spec/rescue_action_spec.rb +0 -87
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 89d0fd9af2111f029883bf00961abfbc4aa88ed5
|
4
|
+
data.tar.gz: d503ca06042d751c61880a42fe603f3010d1f6f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d805dd45ac83a802f8c74352f92e7cda861fed0dd5c3192081a23a81258a8fc87f3b14ef64a93f591efe3a559af2ebbc059dd3d40fb0d7cbf02ee8352b60494
|
7
|
+
data.tar.gz: ef102a70922af14d7c08f5f5850a7dfe6460441d68a29120b94d71e62246f44e98236f4cdc53b6323499622ef67de84ff8f2f65ecf0c7392aa6be9523b52af7c
|
data/.gitignore
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
3
6
|
|
7
|
+
# Ignore gem stuff
|
8
|
+
*.gem
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
flail (0.
|
4
|
+
flail (1.0.0)
|
5
5
|
json
|
6
6
|
|
7
7
|
GEM
|
8
|
-
remote:
|
8
|
+
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
actionpack (2.3.14)
|
11
11
|
activesupport (= 2.3.14)
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
activesupport (2.3.14)
|
16
16
|
diff-lcs (1.1.3)
|
17
17
|
fakeweb (1.3.0)
|
18
|
-
json (1.
|
18
|
+
json (1.8.1)
|
19
19
|
rack (1.1.3)
|
20
20
|
rake (0.9.2.2)
|
21
21
|
rr (1.0.4)
|
data/README.md
CHANGED
@@ -2,8 +2,8 @@ Flail is an exception catcher for Rack applications.
|
|
2
2
|
|
3
3
|
##### Supports
|
4
4
|
|
5
|
-
* Rails 2.3.x
|
6
5
|
* Rails 3.x
|
6
|
+
* (See earlier 0.x.x releases for Rails 2.3.x support)
|
7
7
|
|
8
8
|
|
9
9
|
### Install
|
@@ -14,23 +14,8 @@ gem :flail
|
|
14
14
|
```
|
15
15
|
|
16
16
|
|
17
|
-
###### Rails 2.3.x
|
18
|
-
```ruby
|
19
|
-
gem :flail, :require => false
|
20
|
-
```
|
21
|
-
|
22
|
-
When configuring in the initializer as seen in Usage below be sure to add
|
23
|
-
```ruby
|
24
|
-
require 'flail/rails'
|
25
|
-
```
|
26
|
-
|
27
|
-
so the proper requires are done for Rails 2.3.x
|
28
|
-
|
29
|
-
|
30
|
-
|
31
17
|
### Usage
|
32
18
|
|
33
|
-
|
34
19
|
Add an initializer to configure (or call configure during application startup):
|
35
20
|
|
36
21
|
```ruby
|
@@ -59,10 +44,12 @@ end
|
|
59
44
|
|
60
45
|
|
61
46
|
### Helpful Additions
|
47
|
+
|
62
48
|
See flail_web for a Rails 3 application designed to receive flail exceptions so you can inspect them.
|
63
49
|
https://github.com/asceth/flail_web
|
64
50
|
|
65
|
-
### Author
|
66
51
|
|
52
|
+
### Authors
|
67
53
|
|
68
54
|
Original author: John "asceth" Long
|
55
|
+
Contributor: Ben Fenner
|
data/lib/flail.rb
CHANGED
@@ -6,6 +6,7 @@ require 'flail/base'
|
|
6
6
|
require 'flail/configuration'
|
7
7
|
require 'flail/backtrace'
|
8
8
|
require 'flail/exception'
|
9
|
-
require 'flail/
|
9
|
+
require 'flail/rack_middleware_exception_hook'
|
10
10
|
|
11
|
+
# Railtie is not defined in spec tests so don't require during them.
|
11
12
|
require 'flail/railtie' if defined?(::Rails::Railtie)
|
@@ -1,6 +1,22 @@
|
|
1
1
|
class Flail
|
2
2
|
module Rails
|
3
3
|
module ControllerMethods
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.send(:before_filter, :inject_flail_data_into_environment)
|
7
|
+
end
|
8
|
+
|
9
|
+
# This method is inserted into the host application's controllers as a before_filter
|
10
|
+
# and is used to pass the parameters, session data, user data, and URL data from the app's
|
11
|
+
# controller to the flail gem via the env variable (data is always passed, even if no
|
12
|
+
# exception is thrown). This hook only works when a host app's controller is called.
|
13
|
+
# Routing error exceptions are thrown before the controller is called so those errors are
|
14
|
+
# handled elsewhere and contain less information (mainly the user data is missing).
|
15
|
+
def inject_flail_data_into_environment
|
16
|
+
request.env['flail.request'] ||= request
|
17
|
+
request.env['flail.request.data'] ||= flail_request_data
|
18
|
+
end
|
19
|
+
|
4
20
|
def flail_request_data
|
5
21
|
{
|
6
22
|
:parameters => params.to_hash,
|
data/lib/flail/railtie.rb
CHANGED
@@ -1,20 +1,27 @@
|
|
1
1
|
class Flail
|
2
2
|
class Railtie < ::Rails::Railtie
|
3
|
+
|
4
|
+
# Setup Flail::RackMiddlewareExceptionHook as the first rack middleware
|
5
|
+
# to catch exceptions that happen in the middleware chain.
|
3
6
|
initializer "flail.use_rack_middleware" do |app|
|
4
|
-
app.config.middleware.insert 0, Flail::
|
7
|
+
app.config.middleware.insert 0, Flail::RackMiddlewareExceptionHook
|
5
8
|
end
|
6
9
|
|
10
|
+
# Set the environment and host.
|
7
11
|
config.after_initialize do
|
8
12
|
Flail.configure do
|
9
13
|
environment ::Rails.env
|
10
14
|
host Socket.gethostname
|
11
15
|
end
|
12
16
|
|
17
|
+
# Add methods to the Aciont Controller so they may be run from within the
|
18
|
+
# controller scope. Useful for getting user data and similar.
|
13
19
|
ActiveSupport.on_load(:action_controller) do
|
14
20
|
require 'flail/rails/controller_methods'
|
15
21
|
include Flail::Rails::ControllerMethods
|
16
22
|
end
|
17
23
|
|
24
|
+
# Setup the hooks to catch typical exceptions when they happen.
|
18
25
|
if defined?(::ActionDispatch::DebugExceptions)
|
19
26
|
# Rails 3.2.x
|
20
27
|
require 'flail/rails/action_dispatch'
|
data/lib/flail/version.rb
CHANGED
data/spec/exception_spec.rb
CHANGED
@@ -6,12 +6,15 @@ require 'flail/backtrace'
|
|
6
6
|
require 'flail/exception'
|
7
7
|
|
8
8
|
describe Flail::Exception do
|
9
|
+
|
10
|
+
#Setup flail with dummy handler as these tests aren't very complex.
|
11
|
+
Flail.configure do
|
12
|
+
handle do |payload|
|
13
|
+
# Do nothing.
|
14
|
+
end
|
15
|
+
end
|
9
16
|
|
10
|
-
subject { Flail::Exception.new(
|
11
|
-
SAMPLE_BACKTRACE = [
|
12
|
-
"app/models/user.rb:13:in `magic'",
|
13
|
-
"app/controllers/users_controller.rb:8:in `index'"
|
14
|
-
]
|
17
|
+
subject { Flail::Exception.new(Exception.new, {}) }
|
15
18
|
|
16
19
|
it "should not choke on bad utf-8" do
|
17
20
|
b1r = 0xc0..0xc2
|
@@ -25,7 +28,7 @@ describe Flail::Exception do
|
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
28
|
-
it "should be able to accept
|
31
|
+
it "should be able to accept a generic exception with no request attached" do
|
29
32
|
lambda { Flail::Exception.notify(Exception.new) }.should_not raise_error
|
30
33
|
end
|
31
34
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'ostruct'
|
4
|
-
require 'flail/
|
4
|
+
require 'flail/rack_middleware_exception_hook'
|
5
5
|
|
6
|
-
describe Flail::
|
6
|
+
describe Flail::RackMiddlewareExceptionHook do
|
7
7
|
|
8
|
-
subject { Flail::
|
8
|
+
subject { Flail::RackMiddlewareExceptionHook.new lambda {|env| "val: #{env.fetch(:required_key)}" } }
|
9
9
|
|
10
10
|
context "when an exception is raised by the app" do
|
11
11
|
let(:env) { {} }
|
data/spec/spec_helper.rb
CHANGED
@@ -9,16 +9,12 @@ RSpec.configure do |config|
|
|
9
9
|
config.mock_with :rr
|
10
10
|
end
|
11
11
|
|
12
|
-
require 'action_controller'
|
13
|
-
require 'action_controller/test_process'
|
14
12
|
require 'active_record'
|
15
|
-
require 'active_support'
|
16
13
|
require 'rack'
|
17
14
|
require 'sham_rack'
|
18
15
|
|
19
16
|
require 'flail'
|
20
17
|
require 'flail/rails/controller_methods'
|
21
|
-
require 'flail/rails/rescue_action'
|
22
18
|
|
23
19
|
|
24
20
|
Dir["#{File.expand_path(File.dirname(__FILE__))}/support/*.rb"].map {|file| require(file)}
|
@@ -35,7 +31,6 @@ class FlailArmory
|
|
35
31
|
def build_controller_class(&definition)
|
36
32
|
Class.new(ActionController::Base).tap do |klass|
|
37
33
|
klass.__send__(:include, Flail::Rails::ControllerMethods)
|
38
|
-
klass.__send__(:include, Flail::Rails::RescueAction)
|
39
34
|
klass.class_eval(&definition) if definition
|
40
35
|
|
41
36
|
klass.class_eval do
|
metadata
CHANGED
@@ -1,158 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John 'asceth' Long
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: json
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: actionpack
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 2.3.8
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 2.3.8
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: activerecord
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 2.3.8
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 2.3.8
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: activesupport
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: 2.3.8
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: 2.3.8
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: fakeweb
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- - ~>
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: 1.3.0
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- - ~>
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: 1.3.0
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rake
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: rspec
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - ">="
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: rr
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - ">="
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - ">="
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
- !ruby/object:Gem::Dependency
|
143
126
|
name: sham_rack
|
144
127
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
128
|
requirements:
|
147
|
-
- - ~>
|
129
|
+
- - "~>"
|
148
130
|
- !ruby/object:Gem::Version
|
149
131
|
version: 1.3.0
|
150
132
|
type: :development
|
151
133
|
prerelease: false
|
152
134
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
135
|
requirements:
|
155
|
-
- - ~>
|
136
|
+
- - "~>"
|
156
137
|
- !ruby/object:Gem::Version
|
157
138
|
version: 1.3.0
|
158
139
|
description: Handle Rails exceptions with the fail flail.
|
@@ -162,10 +143,10 @@ executables: []
|
|
162
143
|
extensions: []
|
163
144
|
extra_rdoc_files: []
|
164
145
|
files:
|
165
|
-
- .gemtest
|
166
|
-
- .gitignore
|
167
|
-
- .rspec
|
168
|
-
- .
|
146
|
+
- ".gemtest"
|
147
|
+
- ".gitignore"
|
148
|
+
- ".rspec"
|
149
|
+
- ".ruby-version"
|
169
150
|
- Gemfile
|
170
151
|
- Gemfile.lock
|
171
152
|
- LICENSE
|
@@ -177,50 +158,44 @@ files:
|
|
177
158
|
- lib/flail/base.rb
|
178
159
|
- lib/flail/configuration.rb
|
179
160
|
- lib/flail/exception.rb
|
180
|
-
- lib/flail/
|
181
|
-
- lib/flail/rails.rb
|
161
|
+
- lib/flail/rack_middleware_exception_hook.rb
|
182
162
|
- lib/flail/rails/action_dispatch.rb
|
183
163
|
- lib/flail/rails/controller_methods.rb
|
184
|
-
- lib/flail/rails/rescue_action.rb
|
185
164
|
- lib/flail/railtie.rb
|
186
165
|
- lib/flail/version.rb
|
187
|
-
- rails/init.rb
|
188
166
|
- spec/backtrace_spec.rb
|
189
167
|
- spec/base_spec.rb
|
190
168
|
- spec/exception_spec.rb
|
191
|
-
- spec/
|
192
|
-
- spec/rescue_action_spec.rb
|
169
|
+
- spec/rack_middleware_exception_hook_spec.rb
|
193
170
|
- spec/spec_helper.rb
|
194
171
|
- spec/support/rr.rb
|
195
172
|
homepage: https://github.com/asceth/flail
|
196
173
|
licenses: []
|
174
|
+
metadata: {}
|
197
175
|
post_install_message:
|
198
176
|
rdoc_options: []
|
199
177
|
require_paths:
|
200
178
|
- lib
|
201
179
|
required_ruby_version: !ruby/object:Gem::Requirement
|
202
|
-
none: false
|
203
180
|
requirements:
|
204
|
-
- -
|
181
|
+
- - ">="
|
205
182
|
- !ruby/object:Gem::Version
|
206
183
|
version: '0'
|
207
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
|
-
none: false
|
209
185
|
requirements:
|
210
|
-
- -
|
186
|
+
- - ">="
|
211
187
|
- !ruby/object:Gem::Version
|
212
188
|
version: '0'
|
213
189
|
requirements: []
|
214
190
|
rubyforge_project: flail
|
215
|
-
rubygems_version:
|
191
|
+
rubygems_version: 2.2.0
|
216
192
|
signing_key:
|
217
|
-
specification_version:
|
193
|
+
specification_version: 4
|
218
194
|
summary: Rails exception handler
|
219
195
|
test_files:
|
220
196
|
- spec/backtrace_spec.rb
|
221
197
|
- spec/base_spec.rb
|
222
198
|
- spec/exception_spec.rb
|
223
|
-
- spec/
|
224
|
-
- spec/rescue_action_spec.rb
|
199
|
+
- spec/rack_middleware_exception_hook_spec.rb
|
225
200
|
- spec/spec_helper.rb
|
226
201
|
- spec/support/rr.rb
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use 1.9.3@flail
|
data/lib/flail/rails.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'flail'
|
2
|
-
require 'flail/rails/rescue_action'
|
3
|
-
|
4
|
-
if defined?(::ActionController::Base)
|
5
|
-
::ActionController::Base.send(:include, Flail::Rails::RescueAction)
|
6
|
-
::ActionController::Base.send(:include, Flail::Rails::ControllerMethods)
|
7
|
-
end
|
8
|
-
|
9
|
-
if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:middleware)
|
10
|
-
::Rails.configuration.middleware.insert_after 'ActionController::Failsafe', Flail::Rack
|
11
|
-
end
|
12
|
-
|
13
|
-
Flail.configure do
|
14
|
-
environment(defined?(::Rails.env) && ::Rails.env || defined?(RAILS_ENV) && RAILS_ENV)
|
15
|
-
host Socket.gethostname
|
16
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
class Flail
|
2
|
-
module Rails
|
3
|
-
module RescueAction
|
4
|
-
# Sets up an alias chain to catch exceptions when Rails does
|
5
|
-
def self.included(base)
|
6
|
-
base.send(:alias_method, :rescue_action_in_public_without_flail, :rescue_action_in_public)
|
7
|
-
base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_flail)
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
# Overrides the rescue_action method in ActionController::Base
|
13
|
-
# but uses any custom processing that is defined with
|
14
|
-
# Rails 2's exception helpers.
|
15
|
-
def rescue_action_in_public_with_flail(exception)
|
16
|
-
request.env['flail.request'] = request
|
17
|
-
request.env['flail.request.data'] = flail_request_data
|
18
|
-
|
19
|
-
Flail::Exception.new(request.env, exception).handle!
|
20
|
-
rescue_action_in_public_without_flail(exception)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/rails/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'flail/rails'
|
data/spec/rescue_action_spec.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'ostruct'
|
4
|
-
require 'flail/rails/rescue_action'
|
5
|
-
|
6
|
-
describe Flail::Rails::RescueAction do
|
7
|
-
|
8
|
-
context "catching requests" do
|
9
|
-
before do
|
10
|
-
FlailArmory.setup
|
11
|
-
end
|
12
|
-
|
13
|
-
before(:each) do
|
14
|
-
FlailArmory.raid
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should deliver an exception raised in public requests" do
|
18
|
-
FlailArmory.process_action_with_error
|
19
|
-
FlailArmory.payload.should_not be_nil
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should not deliver exceptions in local requests" do
|
23
|
-
FlailArmory.process_action_with_error(:local => true)
|
24
|
-
FlailArmory.payload.should be_nil
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should not deliver exceptions when all requests are local" do
|
28
|
-
FlailArmory.process_action_with_error(:all_local => true)
|
29
|
-
FlailArmory.payload.should be_nil
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should not deliver exceptions from actions that don't raise" do
|
33
|
-
controller = FlailArmory.process_action { render :text => 'Hello' }
|
34
|
-
|
35
|
-
FlailArmory.payload.should be_nil
|
36
|
-
controller.response.body.should == 'Hello'
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should send session data" do
|
40
|
-
data = {'one' => 'two'}
|
41
|
-
FlailArmory.process_action_with_error(:session => data)
|
42
|
-
|
43
|
-
FlailArmory.payload['session_data'].should == data
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should send user data" do
|
47
|
-
user = OpenStruct.new(:attributes => {:id => 1, :login => 'jlong'})
|
48
|
-
FlailArmory.process_action_with_error(:user => user)
|
49
|
-
|
50
|
-
FlailArmory.payload['user'].should == {'id' => 1, 'login' => 'jlong'}
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should call session.to_hash if available" do
|
54
|
-
hash_data = {:key => :value}
|
55
|
-
|
56
|
-
session = ActionController::TestSession.new
|
57
|
-
stub(ActionController::TestSession).new { session }
|
58
|
-
stub(session).to_hash { hash_data }
|
59
|
-
|
60
|
-
FlailArmory.process_action_with_error
|
61
|
-
|
62
|
-
session.should have_received.to_hash
|
63
|
-
session.should_not have_received.data
|
64
|
-
FlailArmory.payload.should_not be_nil
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should call session.to_hash if available" do
|
68
|
-
hash_data = {:key => :value}
|
69
|
-
|
70
|
-
session = ActionController::TestSession.new
|
71
|
-
stub(ActionController::TestSession).new { session }
|
72
|
-
stub(session).data { hash_data }
|
73
|
-
|
74
|
-
if session.respond_to?(:to_hash)
|
75
|
-
class << session
|
76
|
-
undef :to_hash
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
FlailArmory.process_action_with_error
|
81
|
-
|
82
|
-
session.should_not have_received.to_hash
|
83
|
-
session.should have_received.data
|
84
|
-
FlailArmory.payload.should_not be_nil
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|