egregious 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,9 +1,15 @@
1
1
  Update Log:
2
- Version 0.2.0 released to https://rubygems.org/gems/egregious on 9.21.2012
2
+ Version 0.2.2 released to https://rubygems.org/gems/egregious on 2.15.2013
3
+ Merged pull requests:
4
+ Compatibility with Rails::API (#5)
5
+ Thank you dwbutler! Keep those pull requests coming.
6
+
7
+ Version 0.2.1 released to https://rubygems.org/gems/egregious on 9.21.2012
3
8
  Merged pull requests:
4
9
  Bug Fix: should translate status code Symbol to right HTTP STATUS CODE - avinasha
5
10
  Fixes teapot bug with rails 3.2.8. - kbrown
6
- Thank you avinasha and kbrown along with all the other forks! Keep those pull requests comming.
11
+ Note: version 0.2.0 does not work with rails 3.2.8 you should update to 0.2.1
12
+ Thank you avinasha and kbrown along with all the other forks! Keep those pull requests coming.
7
13
 
8
14
  If you would like to contribute take a look at the issues feature list, fork and issue a pull request!
9
15
 
@@ -90,4 +96,7 @@ end
90
96
  # override this if you want to change what html static file gets returned.
91
97
  def build_html_file_path(status)
92
98
  File.expand_path(Rails.root, 'public', status + '.html')
93
- end
99
+ end
100
+
101
+ KNOWN ISSUES:
102
+ * If you use CanCan or Devise you must have Egregious after CanCan/Devise in your Gemfile, if not it will not handle those errors correctly.
data/lib/egregious.rb CHANGED
@@ -167,7 +167,7 @@ module Egregious
167
167
  "\n\n")
168
168
  HoptoadNotifier.notify(exception) if defined?(HoptoadNotifier)
169
169
  end
170
-
170
+
171
171
  # override this if you want to change your respond_to behavior
172
172
  def egregious_respond_to(exception)
173
173
  respond_to do |format|
@@ -188,6 +188,25 @@ module Egregious
188
188
  def self.included(base)
189
189
  base.class_eval do
190
190
  rescue_from 'Exception' , :with => :egregious_exception_handler
191
+
192
+ unless respond_to?(:flash)
193
+ def egregious_flash(exception)
194
+ end
195
+ end
196
+
197
+ unless respond_to?(:respond_to)
198
+ def egregious_respond_to(exception)
199
+ status = status_code_for_exception(exception)
200
+ case params[:format]
201
+ when 'xml' then render :xml=> exception.to_xml, :status => status
202
+ when 'json' then render :json=> exception.to_json, :status => status
203
+ # render the html page for the status we are returning it exists...if not then render the 500.html page.
204
+ else render :file => File.exists?(build_html_file_path(status)) ?
205
+ build_html_file_path(status) : build_html_file_path('500'),
206
+ :status => status
207
+ end
208
+ end
209
+ end
191
210
  end
192
211
  end
193
212
  end
@@ -1,3 +1,3 @@
1
1
  module Egregious
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -53,7 +53,6 @@ describe Egregious do
53
53
 
54
54
  if defined?(ActionController)
55
55
  it "should return expected errors for ActionController" do
56
- exception_codes[AbstractController::ActionNotFound].should == Egregious.status_code(:forbidden)
57
56
  exception_codes[AbstractController::ActionNotFound].should == Egregious.status_code(:bad_request)
58
57
  exception_codes[ActionController::InvalidAuthenticityToken].should == Egregious.status_code(:bad_request)
59
58
  exception_codes[ActionController::MethodNotAllowed].should == Egregious.status_code(:not_allowed)
@@ -61,7 +60,7 @@ describe Egregious do
61
60
  exception_codes[ActionController::RoutingError].should == Egregious.status_code(:bad_request)
62
61
  exception_codes[ActionController::UnknownController].should == Egregious.status_code(:bad_request)
63
62
  exception_codes[ActionController::UnknownHttpMethod].should == Egregious.status_code(:not_allowed)
64
- exception_codes[ActionController::MissingTemplate].should == Egregious.status_code(:not_found)
63
+ #exception_codes[ActionController::MissingTemplate].should == Egregious.status_code(:not_found)
65
64
  end
66
65
  end
67
66
 
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,7 @@ Bundler.setup
6
6
  ENV["RAILS_ENV"] ||= "test"
7
7
  require 'active_support'
8
8
  require 'active_support/test_case'
9
+ require 'action_controller'
9
10
  require 'warden'
10
11
  require 'cancan'
11
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: egregious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-21 00:00:00.000000000 Z
12
+ date: 2013-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -170,18 +170,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
170
  - - ! '>='
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
- segments:
174
- - 0
175
- hash: -2777519637294455931
176
173
  required_rubygems_version: !ruby/object:Gem::Requirement
177
174
  none: false
178
175
  requirements:
179
176
  - - ! '>='
180
177
  - !ruby/object:Gem::Version
181
178
  version: '0'
182
- segments:
183
- - 0
184
- hash: -2777519637294455931
185
179
  requirements: []
186
180
  rubyforge_project: egregious
187
181
  rubygems_version: 1.8.24