rails_exception_handler 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +19 -17
- data/HISTORY +3 -0
- data/README.markdown +10 -1
- data/VERSION +1 -1
- data/lib/rails_exception_handler/parser.rb +8 -0
- data/rails_exception_handler.gemspec +11 -11
- data/spec/integration/configuration_spec.rb +36 -0
- data/spec/testapp_30/app/controllers/application_controller.rb +4 -0
- data/spec/unit/parser_spec.rb +24 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
@@ -30,7 +30,7 @@ GEM
|
|
30
30
|
activesupport (3.0.9)
|
31
31
|
arel (2.0.10)
|
32
32
|
builder (2.1.2)
|
33
|
-
diff-lcs (1.1.
|
33
|
+
diff-lcs (1.1.3)
|
34
34
|
erubis (2.6.6)
|
35
35
|
abstract (>= 1.0.0)
|
36
36
|
git (1.2.5)
|
@@ -39,6 +39,7 @@ GEM
|
|
39
39
|
bundler (~> 1.0)
|
40
40
|
git (>= 1.2.5)
|
41
41
|
rake
|
42
|
+
json (1.6.4)
|
42
43
|
mail (2.2.19)
|
43
44
|
activesupport (>= 2.3.6)
|
44
45
|
i18n (>= 0.4.0)
|
@@ -47,7 +48,7 @@ GEM
|
|
47
48
|
mime-types (1.16)
|
48
49
|
mysql2 (0.2.6)
|
49
50
|
polyglot (0.3.1)
|
50
|
-
rack (1.2.
|
51
|
+
rack (1.2.5)
|
51
52
|
rack-mount (0.6.14)
|
52
53
|
rack (>= 1.0.0)
|
53
54
|
rack-test (0.5.7)
|
@@ -66,25 +67,26 @@ GEM
|
|
66
67
|
rake (>= 0.8.7)
|
67
68
|
rdoc (~> 3.4)
|
68
69
|
thor (~> 0.14.4)
|
69
|
-
rake (0.9.2)
|
70
|
-
rdoc (3.
|
71
|
-
|
72
|
-
|
73
|
-
rspec-
|
74
|
-
rspec-
|
75
|
-
|
76
|
-
rspec-
|
70
|
+
rake (0.9.2.2)
|
71
|
+
rdoc (3.12)
|
72
|
+
json (~> 1.4)
|
73
|
+
rspec (2.8.0)
|
74
|
+
rspec-core (~> 2.8.0)
|
75
|
+
rspec-expectations (~> 2.8.0)
|
76
|
+
rspec-mocks (~> 2.8.0)
|
77
|
+
rspec-core (2.8.0)
|
78
|
+
rspec-expectations (2.8.0)
|
77
79
|
diff-lcs (~> 1.1.2)
|
78
|
-
rspec-mocks (2.
|
79
|
-
rspec-rails (2.
|
80
|
-
actionpack (
|
81
|
-
activesupport (
|
82
|
-
railties (
|
83
|
-
rspec (~> 2.
|
80
|
+
rspec-mocks (2.8.0)
|
81
|
+
rspec-rails (2.8.1)
|
82
|
+
actionpack (>= 3.0)
|
83
|
+
activesupport (>= 3.0)
|
84
|
+
railties (>= 3.0)
|
85
|
+
rspec (~> 2.8.0)
|
84
86
|
thor (0.14.6)
|
85
87
|
treetop (1.4.9)
|
86
88
|
polyglot (>= 0.3.1)
|
87
|
-
tzinfo (0.3.
|
89
|
+
tzinfo (0.3.31)
|
88
90
|
|
89
91
|
PLATFORMS
|
90
92
|
ruby
|
data/HISTORY
CHANGED
data/README.markdown
CHANGED
@@ -4,7 +4,7 @@ This is an exception handler for Rails 3 built as Rack middleware. It enables yo
|
|
4
4
|
|
5
5
|
## Compatiblity
|
6
6
|
|
7
|
-
The gem
|
7
|
+
The gem should work with all versions of Rails 3. It does not work with Rails 2.
|
8
8
|
See travis-ci for info on which rubies it is tested against:
|
9
9
|
http://travis-ci.org/#!/Sharagoz/rails_exception_handler
|
10
10
|
|
@@ -26,6 +26,7 @@ RailsExceptionHandler.configure do |config|
|
|
26
26
|
# config.filters = [ # No filters are enabled by default
|
27
27
|
# :all_404s,
|
28
28
|
# :no_referer_404s,
|
29
|
+
# :anon_404s,
|
29
30
|
# {:user_agent_regxp => /\b(ApptusBot|TurnitinBot|DotBot|SiteBot)\b/i},
|
30
31
|
# {:target_url_regxp => /\b(myphpadmin)\b/i}
|
31
32
|
# ]
|
@@ -121,6 +122,14 @@ config.filters = [:all_404s]
|
|
121
122
|
When turned on the following exceptions will no longer be stored: ActionController::RoutingError, AbstractController::ActionNotFound, ActiveRecord::RecordNotFound
|
122
123
|
Consider this a last resort. You will miss all "real" 404s when this is turned on, like broken redirections.
|
123
124
|
|
125
|
+
**:all_404s**
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
config.filters = [:anon_404s]
|
129
|
+
```
|
130
|
+
|
131
|
+
When turned on the following exceptions will no longer be stored unless a user is logged in: ActionController::RoutingError, AbstractController::ActionNotFound, ActiveRecord::RecordNotFound
|
132
|
+
|
124
133
|
**:no_referer_404s**
|
125
134
|
|
126
135
|
```ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
@@ -40,6 +40,10 @@ class RailsExceptionHandler::Parser
|
|
40
40
|
routing_errors.include?(@exception.class.to_s)
|
41
41
|
end
|
42
42
|
|
43
|
+
def anon_user?
|
44
|
+
[nil,'Anonymous'].include?(user_info)
|
45
|
+
end
|
46
|
+
|
43
47
|
private
|
44
48
|
|
45
49
|
def blank_referer?
|
@@ -61,6 +65,10 @@ class RailsExceptionHandler::Parser
|
|
61
65
|
routing_error? && blank_referer?
|
62
66
|
end
|
63
67
|
|
68
|
+
def filter_anon_404s
|
69
|
+
routing_error? && anon_user?
|
70
|
+
end
|
71
|
+
|
64
72
|
def filter_user_agent_regxp(regxp)
|
65
73
|
result = relevant_info[:user_agent].match(regxp)
|
66
74
|
result != nil
|
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "1.
|
7
|
+
s.name = "rails_exception_handler"
|
8
|
+
s.version = "1.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["Sharagoz"]
|
12
|
+
s.date = "2012-01-13"
|
13
|
+
s.description = ""
|
14
|
+
s.email = "contact@sharagoz.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.markdown"
|
17
17
|
]
|
@@ -70,11 +70,11 @@ Gem::Specification.new do |s|
|
|
70
70
|
"spec/unit/handler_spec.rb",
|
71
71
|
"spec/unit/parser_spec.rb"
|
72
72
|
]
|
73
|
-
s.homepage =
|
74
|
-
s.licenses = [
|
75
|
-
s.require_paths = [
|
76
|
-
s.rubygems_version =
|
77
|
-
s.summary =
|
73
|
+
s.homepage = "http://github.com/Sharagoz/rails_exception_handler"
|
74
|
+
s.licenses = ["MIT"]
|
75
|
+
s.require_paths = ["lib"]
|
76
|
+
s.rubygems_version = "1.8.11"
|
77
|
+
s.summary = "Exception Handling for Rails 3"
|
78
78
|
|
79
79
|
if s.respond_to? :specification_version then
|
80
80
|
s.specification_version = 3
|
@@ -53,6 +53,7 @@ describe RailsExceptionHandler::Configuration do
|
|
53
53
|
get "/home/view_error"
|
54
54
|
ErrorMessage.count.should == 1
|
55
55
|
end
|
56
|
+
|
56
57
|
end
|
57
58
|
|
58
59
|
describe ":user_agent_regxp" do
|
@@ -82,6 +83,41 @@ describe RailsExceptionHandler::Configuration do
|
|
82
83
|
ErrorMessage.count.should == 1
|
83
84
|
end
|
84
85
|
end
|
86
|
+
|
87
|
+
describe ":anon_404s" do
|
88
|
+
it "should log a 404 from a logged in user" do
|
89
|
+
RailsExceptionHandler.configure do |config|
|
90
|
+
config.environments = [Rails.env.to_sym]
|
91
|
+
config.storage_strategies = [:active_record]
|
92
|
+
config.store_user_info = {:method => :current_user, :field => :login}
|
93
|
+
config.filters = [:anon_404s]
|
94
|
+
end
|
95
|
+
get "/incorrect_route"
|
96
|
+
ErrorMessage.count.should == 1
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should filter 404s from anonymous users" do
|
100
|
+
RailsExceptionHandler.configure do |config|
|
101
|
+
config.environments = [Rails.env.to_sym]
|
102
|
+
config.storage_strategies = [:active_record]
|
103
|
+
config.store_user_info = {:method => :nil_user, :field => :login}
|
104
|
+
config.filters = [:anon_404s]
|
105
|
+
end
|
106
|
+
get "/incorrect_route"
|
107
|
+
ErrorMessage.count.should == 0
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should not filter 500s from anonymous users" do
|
111
|
+
RailsExceptionHandler.configure do |config|
|
112
|
+
config.environments = [Rails.env.to_sym]
|
113
|
+
config.storage_strategies = [:active_record]
|
114
|
+
config.store_user_info = {:method => :nil_user, :field => :login}
|
115
|
+
config.filters = [:anon_404s]
|
116
|
+
end
|
117
|
+
get "/home/model_error"
|
118
|
+
ErrorMessage.count.should == 1
|
119
|
+
end
|
120
|
+
end
|
85
121
|
end
|
86
122
|
|
87
123
|
describe ".environments" do
|
data/spec/unit/parser_spec.rb
CHANGED
@@ -109,4 +109,28 @@ describe RailsExceptionHandler::Parser do
|
|
109
109
|
parser.relevant_info[:user_info].should == nil
|
110
110
|
end
|
111
111
|
end
|
112
|
+
|
113
|
+
describe "anon_user?" do
|
114
|
+
it "should return true if user_info is nil" do
|
115
|
+
RailsExceptionHandler.configure {|config| config.store_user_info = false}
|
116
|
+
controller = mock(ApplicationController)
|
117
|
+
parser = create_parser(nil, nil, controller)
|
118
|
+
parser.anon_user?.should be_true
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should return true if user_info is 'Anonymous'" do
|
122
|
+
RailsExceptionHandler.configure {|config| config.store_user_info = {:method => :current_user, :field => :login}}
|
123
|
+
controller = mock(ApplicationController, :current_user => nil)
|
124
|
+
parser = create_parser(nil, nil, controller)
|
125
|
+
parser.relevant_info[:user_info].should == 'Anonymous'
|
126
|
+
parser.anon_user?.should be_true
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should return false if user info is present" do
|
130
|
+
RailsExceptionHandler.configure {|config| config.store_user_info = {:method => :current_user, :field => :login}}
|
131
|
+
controller = mock(ApplicationController, :current_user => mock(Object, :login => 'matz'))
|
132
|
+
parser = create_parser(nil, nil, controller)
|
133
|
+
parser.anon_user?.should be_false
|
134
|
+
end
|
135
|
+
end
|
112
136
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rails_exception_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.3.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sharagoz
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2012-01-13 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
requirements: []
|
153
153
|
|
154
154
|
rubyforge_project:
|
155
|
-
rubygems_version: 1.8.
|
155
|
+
rubygems_version: 1.8.11
|
156
156
|
signing_key:
|
157
157
|
specification_version: 3
|
158
158
|
summary: Exception Handling for Rails 3
|