Skip to content

Commit

Permalink
rails 4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorntrondsen committed Jun 14, 2013
1 parent 6c8677c commit e7b1d16
Show file tree
Hide file tree
Showing 52 changed files with 610 additions and 106 deletions.
9 changes: 6 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ source "http://rubygems.org"

group :test, :development do

gem "rails", '3.0.20'
gem "rack-test", '0.5.7'
#gem "rails", '3.0.20'
#gem "rack-test", '0.5.7'

#gem "rails", '3.2.13'
#gem "rack-test", '0.6.1'
#gem "rack-test", '0.6.2'

gem "rails", '4.0.0.rc2'
gem "rack-test", '0.6.2'

gem 'sqlite3'
gem 'pry'
Expand Down
119 changes: 63 additions & 56 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,80 +6,75 @@ PATH
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.20)
actionpack (= 3.0.20)
mail (~> 2.2.19)
actionpack (3.0.20)
activemodel (= 3.0.20)
activesupport (= 3.0.20)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.5)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.20)
activesupport (= 3.0.20)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.20)
activemodel (= 3.0.20)
activesupport (= 3.0.20)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activeresource (3.0.20)
activemodel (= 3.0.20)
activesupport (= 3.0.20)
activesupport (3.0.20)
arel (2.0.10)
builder (2.1.2)
actionmailer (4.0.0.rc2)
actionpack (= 4.0.0.rc2)
mail (~> 2.5.3)
actionpack (4.0.0.rc2)
activesupport (= 4.0.0.rc2)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.0.rc2)
activesupport (= 4.0.0.rc2)
builder (~> 3.1.0)
activerecord (4.0.0.rc2)
activemodel (= 4.0.0.rc2)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.0.rc2)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.0.rc2)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
arel (4.0.0)
atomic (1.1.9)
builder (3.1.4)
coderay (1.0.9)
diff-lcs (1.2.4)
erubis (2.6.6)
abstract (>= 1.0.0)
erubis (2.7.0)
git (1.2.5)
i18n (0.5.0)
hike (1.2.3)
i18n (0.6.4)
jeweler (1.8.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rdoc
json (1.8.0)
mail (2.2.20)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.8.1)
mime-types (1.23)
minitest (4.7.4)
multi_json (1.7.7)
polyglot (0.3.3)
pry (0.9.12.2)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
rack (1.2.8)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rails (3.0.20)
actionmailer (= 3.0.20)
actionpack (= 3.0.20)
activerecord (= 3.0.20)
activeresource (= 3.0.20)
activesupport (= 3.0.20)
bundler (~> 1.0)
railties (= 3.0.20)
railties (3.0.20)
actionpack (= 3.0.20)
activesupport (= 3.0.20)
rails (4.0.0.rc2)
actionmailer (= 4.0.0.rc2)
actionpack (= 4.0.0.rc2)
activerecord (= 4.0.0.rc2)
activesupport (= 4.0.0.rc2)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.0.rc2)
sprockets-rails (~> 2.0.0)
railties (4.0.0.rc2)
actionpack (= 4.0.0.rc2)
activesupport (= 4.0.0.rc2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
thor (>= 0.18.1, < 2.0)
rake (10.0.4)
rdoc (3.12.2)
rdoc (4.0.1)
json (~> 1.4)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
Expand All @@ -93,8 +88,20 @@ GEM
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
slop (3.4.5)
sprockets (2.10.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.7)
thor (0.14.6)
thor (0.18.1)
thread_safe (0.1.0)
atomic
tilt (1.4.1)
treetop (1.4.14)
polyglot
polyglot (>= 0.3.1)
Expand All @@ -106,8 +113,8 @@ PLATFORMS
DEPENDENCIES
jeweler
pry
rack-test (= 0.5.7)
rails (= 3.0.20)
rack-test (= 0.6.2)
rails (= 4.0.0.rc2)
rails_exception_handler!
rspec-rails
sqlite3
4 changes: 3 additions & 1 deletion lib/rails_exception_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def self.configure
yield configuration
return unless configuration.activate?

Rails.configuration.middleware.use(RailsExceptionHandler)
unless Rails.configuration.middleware.class == ActionDispatch::MiddlewareStack && Rails.configuration.middleware.include?(RailsExceptionHandler)
Rails.configuration.middleware.use(RailsExceptionHandler)
end

Rails.configuration.action_dispatch.show_exceptions = true
Rails.configuration.consider_all_requests_local = false
Expand Down
13 changes: 0 additions & 13 deletions lib/rails_exception_handler/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def initialize
@fallback_layout = 'application'
@response_mapping = {}
@responses = {}
@whitelisted = false
end

def active_record?
Expand Down Expand Up @@ -43,16 +42,4 @@ def store_exception_info(&block)
def store_request_info(&block)
@request_info_block = block
end

def whitelist(fields)
return if(whitelisted?)
ErrorMessage.send(:attr_accessible, *fields)
@whitelisted = true
end

private

def whitelisted?
@whitelisted
end
end
7 changes: 5 additions & 2 deletions lib/rails_exception_handler/storage.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
class RailsExceptionHandler::Storage
def self.active_record(info)
RailsExceptionHandler.configuration.whitelist(info.keys)
ErrorMessage.create(info)
if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR > 0
ErrorMessage.create(info, :without_protection => true)
else
ErrorMessage.create(info)
end
end

def self.rails_log(info)
Expand Down
23 changes: 16 additions & 7 deletions rails_exception_handler.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ Gem::Specification.new do |s|
"spec/dummy_32/.gitignore",
"spec/dummy_32/app/mailers/.gitkeep",
"spec/dummy_32/app/models/.gitkeep",
"spec/dummy_32/log/.gitkeep"
"spec/dummy_32/log/.gitkeep",
"spec/dummy_40/.gitignore",
"spec/dummy_40/app/assets/images/.keep",
"spec/dummy_40/app/controllers/concerns/.keep",
"spec/dummy_40/app/mailers/.keep",
"spec/dummy_40/app/models/.keep",
"spec/dummy_40/app/models/concerns/.keep",
"spec/dummy_40/lib/assets/.keep",
"spec/dummy_40/lib/tasks/.keep",
"spec/dummy_40/log/.keep"
]
s.homepage = "http://github.com/Sharagoz/rails_exception_handler"
s.licenses = ["MIT"]
Expand All @@ -53,25 +62,25 @@ Gem::Specification.new do |s|
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<rails>, ["= 3.2.13"])
s.add_development_dependency(%q<rack-test>, ["= 0.6.1"])
s.add_development_dependency(%q<rails>, ["= 4.0.0.rc2"])
s.add_development_dependency(%q<rack-test>, ["= 0.6.2"])
s.add_development_dependency(%q<sqlite3>, [">= 0"])
s.add_development_dependency(%q<pry>, [">= 0"])
s.add_development_dependency(%q<rspec-rails>, [">= 0"])
s.add_development_dependency(%q<jeweler>, [">= 0"])
s.add_development_dependency(%q<rails_exception_handler>, [">= 0"])
else
s.add_dependency(%q<rails>, ["= 3.2.13"])
s.add_dependency(%q<rack-test>, ["= 0.6.1"])
s.add_dependency(%q<rails>, ["= 4.0.0.rc2"])
s.add_dependency(%q<rack-test>, ["= 0.6.2"])
s.add_dependency(%q<sqlite3>, [">= 0"])
s.add_dependency(%q<pry>, [">= 0"])
s.add_dependency(%q<rspec-rails>, [">= 0"])
s.add_dependency(%q<jeweler>, [">= 0"])
s.add_dependency(%q<rails_exception_handler>, [">= 0"])
end
else
s.add_dependency(%q<rails>, ["= 3.2.13"])
s.add_dependency(%q<rack-test>, ["= 0.6.1"])
s.add_dependency(%q<rails>, ["= 4.0.0.rc2"])
s.add_dependency(%q<rack-test>, ["= 0.6.2"])
s.add_dependency(%q<sqlite3>, [">= 0"])
s.add_dependency(%q<pry>, [">= 0"])
s.add_dependency(%q<rspec-rails>, [">= 0"])
Expand Down
Binary file modified spec/db/test.sqlite3
Binary file not shown.
16 changes: 16 additions & 0 deletions spec/dummy_40/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
6 changes: 6 additions & 0 deletions spec/dummy_40/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

ExceptionHandlerTestApp::Application.load_tasks
Empty file.
13 changes: 13 additions & 0 deletions spec/dummy_40/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_tree .
13 changes: 13 additions & 0 deletions spec/dummy_40/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
18 changes: 18 additions & 0 deletions spec/dummy_40/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception

def current_user
mock = Object.new
def mock.login
'matz'
end
return mock
end

def nil_user
return nil
end

end
Empty file.
25 changes: 25 additions & 0 deletions spec/dummy_40/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class HomeController < ApplicationController

def controller_error
nil.foo
render(:text => 'did not fail')
end

def model_error
s = StoredException.new
s.failure
render(:text => 'did not fail')
end

def view_error
end

def custom_layout
render :action => 'view_error', :layout => 'custom'
end

def syntax_error
eval("arr = [")
render(:text => 'did not fail')
end
end
2 changes: 2 additions & 0 deletions spec/dummy_40/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationHelper
end
Empty file added spec/dummy_40/app/mailers/.keep
Empty file.
Empty file added spec/dummy_40/app/models/.keep
Empty file.
Empty file.
9 changes: 9 additions & 0 deletions spec/dummy_40/app/models/stored_exception.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Only used for testing model errors
class StoredException < ActiveRecord::Base
self.table_name = :error_messages


def failure
nil.foo
end
end
2 changes: 2 additions & 0 deletions spec/dummy_40/app/views/home/view_error.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%= nil.foo %>
Loading

0 comments on commit e7b1d16

Please sign in to comment.