From d9fad70b612a96225c09dbb77663b988d4d3a5e4 Mon Sep 17 00:00:00 2001 From: David Czarnecki Date: Fri, 2 Sep 2011 17:12:49 -0400 Subject: [PATCH 1/4] Test that errship actually gets the ActiveRecord::RecordNotFound exception --- Gemfile | 1 + Gemfile.lock | 2 ++ test/{sandbox => active_record_sandbox}/.gitignore | 0 test/{sandbox => active_record_sandbox}/Gemfile | 0 .../{sandbox => active_record_sandbox}/Gemfile.lock | 0 test/{sandbox => active_record_sandbox}/README | 0 test/{sandbox => active_record_sandbox}/Rakefile | 0 .../app/assets/javascripts/brains.js | 0 .../app/assets/stylesheets/application.css | 0 .../app/assets/stylesheets/brains.css | 0 .../app/controllers/application_controller.rb | 0 .../app/controllers/brains_controller.rb | 2 -- .../app/helpers/application_helper.rb | 0 .../app/helpers/brains_helper.rb | 0 test/active_record_sandbox/app/models/user.rb | 2 ++ .../app/views/layouts/application.html.erb | 0 test/{sandbox => active_record_sandbox}/config.ru | 0 .../config/application.rb | 0 .../config/boot.rb | 0 .../config/database.yml | 0 .../config/environment.rb | 0 .../config/environments/development.rb | 0 .../config/environments/production.rb | 0 .../config/environments/test.rb | 0 .../config/initializers/backtrace_silencers.rb | 0 .../config/initializers/inflections.rb | 0 .../config/initializers/mime_types.rb | 0 .../config/initializers/secret_token.rb | 0 .../config/initializers/session_store.rb | 0 .../config/initializers/wrap_parameters.rb | 0 .../config/locales/en.yml | 0 .../config/routes.rb | 0 .../db/migrate/20110830181342_add_sessions_table.rb | 0 .../{sandbox => active_record_sandbox}/db/schema.rb | 0 test/{sandbox => active_record_sandbox}/db/seeds.rb | 0 .../lib/tasks/.gitkeep | 0 .../public/404.html | 0 .../public/422.html | 0 .../public/500.html | 0 .../public/favicon.ico | 0 .../public/images/rails.png | Bin .../public/javascripts/application.js | 0 .../public/javascripts/controls.js | 0 .../public/javascripts/dragdrop.js | 0 .../public/javascripts/effects.js | 0 .../public/javascripts/prototype.js | 0 .../public/javascripts/rails.js | 0 .../public/robots.txt | 0 .../public/stylesheets/.gitkeep | 0 .../{sandbox => active_record_sandbox}/script/rails | 0 .../test/functional/brains_controller_test.rb | 9 +++++++++ .../test/test_helper.rb | 0 .../vendor/plugins/.gitkeep | 0 .../test/functional/brains_controller_test.rb | 7 ------- .../sandbox/test/unit/helpers/brains_helper_test.rb | 4 ---- test/test_helper.rb | 3 ++- 56 files changed, 16 insertions(+), 14 deletions(-) rename test/{sandbox => active_record_sandbox}/.gitignore (100%) rename test/{sandbox => active_record_sandbox}/Gemfile (100%) rename test/{sandbox => active_record_sandbox}/Gemfile.lock (100%) rename test/{sandbox => active_record_sandbox}/README (100%) rename test/{sandbox => active_record_sandbox}/Rakefile (100%) rename test/{sandbox => active_record_sandbox}/app/assets/javascripts/brains.js (100%) rename test/{sandbox => active_record_sandbox}/app/assets/stylesheets/application.css (100%) rename test/{sandbox => active_record_sandbox}/app/assets/stylesheets/brains.css (100%) rename test/{sandbox => active_record_sandbox}/app/controllers/application_controller.rb (100%) rename test/{sandbox => active_record_sandbox}/app/controllers/brains_controller.rb (53%) rename test/{sandbox => active_record_sandbox}/app/helpers/application_helper.rb (100%) rename test/{sandbox => active_record_sandbox}/app/helpers/brains_helper.rb (100%) create mode 100644 test/active_record_sandbox/app/models/user.rb rename test/{sandbox => active_record_sandbox}/app/views/layouts/application.html.erb (100%) rename test/{sandbox => active_record_sandbox}/config.ru (100%) rename test/{sandbox => active_record_sandbox}/config/application.rb (100%) rename test/{sandbox => active_record_sandbox}/config/boot.rb (100%) rename test/{sandbox => active_record_sandbox}/config/database.yml (100%) rename test/{sandbox => active_record_sandbox}/config/environment.rb (100%) rename test/{sandbox => active_record_sandbox}/config/environments/development.rb (100%) rename test/{sandbox => active_record_sandbox}/config/environments/production.rb (100%) rename test/{sandbox => active_record_sandbox}/config/environments/test.rb (100%) rename test/{sandbox => active_record_sandbox}/config/initializers/backtrace_silencers.rb (100%) rename test/{sandbox => active_record_sandbox}/config/initializers/inflections.rb (100%) rename test/{sandbox => active_record_sandbox}/config/initializers/mime_types.rb (100%) rename test/{sandbox => active_record_sandbox}/config/initializers/secret_token.rb (100%) rename test/{sandbox => active_record_sandbox}/config/initializers/session_store.rb (100%) rename test/{sandbox => active_record_sandbox}/config/initializers/wrap_parameters.rb (100%) rename test/{sandbox => active_record_sandbox}/config/locales/en.yml (100%) rename test/{sandbox => active_record_sandbox}/config/routes.rb (100%) rename test/{sandbox => active_record_sandbox}/db/migrate/20110830181342_add_sessions_table.rb (100%) rename test/{sandbox => active_record_sandbox}/db/schema.rb (100%) rename test/{sandbox => active_record_sandbox}/db/seeds.rb (100%) rename test/{sandbox => active_record_sandbox}/lib/tasks/.gitkeep (100%) rename test/{sandbox => active_record_sandbox}/public/404.html (100%) rename test/{sandbox => active_record_sandbox}/public/422.html (100%) rename test/{sandbox => active_record_sandbox}/public/500.html (100%) rename test/{sandbox => active_record_sandbox}/public/favicon.ico (100%) rename test/{sandbox => active_record_sandbox}/public/images/rails.png (100%) rename test/{sandbox => active_record_sandbox}/public/javascripts/application.js (100%) rename test/{sandbox => active_record_sandbox}/public/javascripts/controls.js (100%) rename test/{sandbox => active_record_sandbox}/public/javascripts/dragdrop.js (100%) rename test/{sandbox => active_record_sandbox}/public/javascripts/effects.js (100%) rename test/{sandbox => active_record_sandbox}/public/javascripts/prototype.js (100%) rename test/{sandbox => active_record_sandbox}/public/javascripts/rails.js (100%) rename test/{sandbox => active_record_sandbox}/public/robots.txt (100%) rename test/{sandbox => active_record_sandbox}/public/stylesheets/.gitkeep (100%) rename test/{sandbox => active_record_sandbox}/script/rails (100%) create mode 100644 test/active_record_sandbox/test/functional/brains_controller_test.rb rename test/{sandbox => active_record_sandbox}/test/test_helper.rb (100%) rename test/{sandbox => active_record_sandbox}/vendor/plugins/.gitkeep (100%) delete mode 100644 test/sandbox/test/functional/brains_controller_test.rb delete mode 100644 test/sandbox/test/unit/helpers/brains_helper_test.rb diff --git a/Gemfile b/Gemfile index 854ba16..475d383 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,7 @@ group :test do gem 'rails', '3.1.0' gem 'sqlite3-ruby' gem 'turn' + gem 'mocha', :require => false end gem 'haml' diff --git a/Gemfile.lock b/Gemfile.lock index 16e0bc2..f954119 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -48,6 +48,7 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.16) + mocha (0.9.12) multi_json (1.0.3) polyglot (0.3.2) rack (1.3.2) @@ -101,6 +102,7 @@ DEPENDENCIES bundler (~> 1.0.0) haml jeweler (~> 1.6.0) + mocha rails (= 3.1.0) rake (= 0.8.7) rcov diff --git a/test/sandbox/.gitignore b/test/active_record_sandbox/.gitignore similarity index 100% rename from test/sandbox/.gitignore rename to test/active_record_sandbox/.gitignore diff --git a/test/sandbox/Gemfile b/test/active_record_sandbox/Gemfile similarity index 100% rename from test/sandbox/Gemfile rename to test/active_record_sandbox/Gemfile diff --git a/test/sandbox/Gemfile.lock b/test/active_record_sandbox/Gemfile.lock similarity index 100% rename from test/sandbox/Gemfile.lock rename to test/active_record_sandbox/Gemfile.lock diff --git a/test/sandbox/README b/test/active_record_sandbox/README similarity index 100% rename from test/sandbox/README rename to test/active_record_sandbox/README diff --git a/test/sandbox/Rakefile b/test/active_record_sandbox/Rakefile similarity index 100% rename from test/sandbox/Rakefile rename to test/active_record_sandbox/Rakefile diff --git a/test/sandbox/app/assets/javascripts/brains.js b/test/active_record_sandbox/app/assets/javascripts/brains.js similarity index 100% rename from test/sandbox/app/assets/javascripts/brains.js rename to test/active_record_sandbox/app/assets/javascripts/brains.js diff --git a/test/sandbox/app/assets/stylesheets/application.css b/test/active_record_sandbox/app/assets/stylesheets/application.css similarity index 100% rename from test/sandbox/app/assets/stylesheets/application.css rename to test/active_record_sandbox/app/assets/stylesheets/application.css diff --git a/test/sandbox/app/assets/stylesheets/brains.css b/test/active_record_sandbox/app/assets/stylesheets/brains.css similarity index 100% rename from test/sandbox/app/assets/stylesheets/brains.css rename to test/active_record_sandbox/app/assets/stylesheets/brains.css diff --git a/test/sandbox/app/controllers/application_controller.rb b/test/active_record_sandbox/app/controllers/application_controller.rb similarity index 100% rename from test/sandbox/app/controllers/application_controller.rb rename to test/active_record_sandbox/app/controllers/application_controller.rb diff --git a/test/sandbox/app/controllers/brains_controller.rb b/test/active_record_sandbox/app/controllers/brains_controller.rb similarity index 53% rename from test/sandbox/app/controllers/brains_controller.rb rename to test/active_record_sandbox/app/controllers/brains_controller.rb index ef419cc..9876a62 100644 --- a/test/sandbox/app/controllers/brains_controller.rb +++ b/test/active_record_sandbox/app/controllers/brains_controller.rb @@ -1,6 +1,4 @@ class BrainsController < ApplicationController - rescue_from ActiveRecord::RecordNotFound, :with => ->(e){ render_404_error e, 'brainless' } - def index raise ActiveRecord::RecordNotFound end diff --git a/test/sandbox/app/helpers/application_helper.rb b/test/active_record_sandbox/app/helpers/application_helper.rb similarity index 100% rename from test/sandbox/app/helpers/application_helper.rb rename to test/active_record_sandbox/app/helpers/application_helper.rb diff --git a/test/sandbox/app/helpers/brains_helper.rb b/test/active_record_sandbox/app/helpers/brains_helper.rb similarity index 100% rename from test/sandbox/app/helpers/brains_helper.rb rename to test/active_record_sandbox/app/helpers/brains_helper.rb diff --git a/test/active_record_sandbox/app/models/user.rb b/test/active_record_sandbox/app/models/user.rb new file mode 100644 index 0000000..431cf7b --- /dev/null +++ b/test/active_record_sandbox/app/models/user.rb @@ -0,0 +1,2 @@ +class User < ActiveRecord::Base +end \ No newline at end of file diff --git a/test/sandbox/app/views/layouts/application.html.erb b/test/active_record_sandbox/app/views/layouts/application.html.erb similarity index 100% rename from test/sandbox/app/views/layouts/application.html.erb rename to test/active_record_sandbox/app/views/layouts/application.html.erb diff --git a/test/sandbox/config.ru b/test/active_record_sandbox/config.ru similarity index 100% rename from test/sandbox/config.ru rename to test/active_record_sandbox/config.ru diff --git a/test/sandbox/config/application.rb b/test/active_record_sandbox/config/application.rb similarity index 100% rename from test/sandbox/config/application.rb rename to test/active_record_sandbox/config/application.rb diff --git a/test/sandbox/config/boot.rb b/test/active_record_sandbox/config/boot.rb similarity index 100% rename from test/sandbox/config/boot.rb rename to test/active_record_sandbox/config/boot.rb diff --git a/test/sandbox/config/database.yml b/test/active_record_sandbox/config/database.yml similarity index 100% rename from test/sandbox/config/database.yml rename to test/active_record_sandbox/config/database.yml diff --git a/test/sandbox/config/environment.rb b/test/active_record_sandbox/config/environment.rb similarity index 100% rename from test/sandbox/config/environment.rb rename to test/active_record_sandbox/config/environment.rb diff --git a/test/sandbox/config/environments/development.rb b/test/active_record_sandbox/config/environments/development.rb similarity index 100% rename from test/sandbox/config/environments/development.rb rename to test/active_record_sandbox/config/environments/development.rb diff --git a/test/sandbox/config/environments/production.rb b/test/active_record_sandbox/config/environments/production.rb similarity index 100% rename from test/sandbox/config/environments/production.rb rename to test/active_record_sandbox/config/environments/production.rb diff --git a/test/sandbox/config/environments/test.rb b/test/active_record_sandbox/config/environments/test.rb similarity index 100% rename from test/sandbox/config/environments/test.rb rename to test/active_record_sandbox/config/environments/test.rb diff --git a/test/sandbox/config/initializers/backtrace_silencers.rb b/test/active_record_sandbox/config/initializers/backtrace_silencers.rb similarity index 100% rename from test/sandbox/config/initializers/backtrace_silencers.rb rename to test/active_record_sandbox/config/initializers/backtrace_silencers.rb diff --git a/test/sandbox/config/initializers/inflections.rb b/test/active_record_sandbox/config/initializers/inflections.rb similarity index 100% rename from test/sandbox/config/initializers/inflections.rb rename to test/active_record_sandbox/config/initializers/inflections.rb diff --git a/test/sandbox/config/initializers/mime_types.rb b/test/active_record_sandbox/config/initializers/mime_types.rb similarity index 100% rename from test/sandbox/config/initializers/mime_types.rb rename to test/active_record_sandbox/config/initializers/mime_types.rb diff --git a/test/sandbox/config/initializers/secret_token.rb b/test/active_record_sandbox/config/initializers/secret_token.rb similarity index 100% rename from test/sandbox/config/initializers/secret_token.rb rename to test/active_record_sandbox/config/initializers/secret_token.rb diff --git a/test/sandbox/config/initializers/session_store.rb b/test/active_record_sandbox/config/initializers/session_store.rb similarity index 100% rename from test/sandbox/config/initializers/session_store.rb rename to test/active_record_sandbox/config/initializers/session_store.rb diff --git a/test/sandbox/config/initializers/wrap_parameters.rb b/test/active_record_sandbox/config/initializers/wrap_parameters.rb similarity index 100% rename from test/sandbox/config/initializers/wrap_parameters.rb rename to test/active_record_sandbox/config/initializers/wrap_parameters.rb diff --git a/test/sandbox/config/locales/en.yml b/test/active_record_sandbox/config/locales/en.yml similarity index 100% rename from test/sandbox/config/locales/en.yml rename to test/active_record_sandbox/config/locales/en.yml diff --git a/test/sandbox/config/routes.rb b/test/active_record_sandbox/config/routes.rb similarity index 100% rename from test/sandbox/config/routes.rb rename to test/active_record_sandbox/config/routes.rb diff --git a/test/sandbox/db/migrate/20110830181342_add_sessions_table.rb b/test/active_record_sandbox/db/migrate/20110830181342_add_sessions_table.rb similarity index 100% rename from test/sandbox/db/migrate/20110830181342_add_sessions_table.rb rename to test/active_record_sandbox/db/migrate/20110830181342_add_sessions_table.rb diff --git a/test/sandbox/db/schema.rb b/test/active_record_sandbox/db/schema.rb similarity index 100% rename from test/sandbox/db/schema.rb rename to test/active_record_sandbox/db/schema.rb diff --git a/test/sandbox/db/seeds.rb b/test/active_record_sandbox/db/seeds.rb similarity index 100% rename from test/sandbox/db/seeds.rb rename to test/active_record_sandbox/db/seeds.rb diff --git a/test/sandbox/lib/tasks/.gitkeep b/test/active_record_sandbox/lib/tasks/.gitkeep similarity index 100% rename from test/sandbox/lib/tasks/.gitkeep rename to test/active_record_sandbox/lib/tasks/.gitkeep diff --git a/test/sandbox/public/404.html b/test/active_record_sandbox/public/404.html similarity index 100% rename from test/sandbox/public/404.html rename to test/active_record_sandbox/public/404.html diff --git a/test/sandbox/public/422.html b/test/active_record_sandbox/public/422.html similarity index 100% rename from test/sandbox/public/422.html rename to test/active_record_sandbox/public/422.html diff --git a/test/sandbox/public/500.html b/test/active_record_sandbox/public/500.html similarity index 100% rename from test/sandbox/public/500.html rename to test/active_record_sandbox/public/500.html diff --git a/test/sandbox/public/favicon.ico b/test/active_record_sandbox/public/favicon.ico similarity index 100% rename from test/sandbox/public/favicon.ico rename to test/active_record_sandbox/public/favicon.ico diff --git a/test/sandbox/public/images/rails.png b/test/active_record_sandbox/public/images/rails.png similarity index 100% rename from test/sandbox/public/images/rails.png rename to test/active_record_sandbox/public/images/rails.png diff --git a/test/sandbox/public/javascripts/application.js b/test/active_record_sandbox/public/javascripts/application.js similarity index 100% rename from test/sandbox/public/javascripts/application.js rename to test/active_record_sandbox/public/javascripts/application.js diff --git a/test/sandbox/public/javascripts/controls.js b/test/active_record_sandbox/public/javascripts/controls.js similarity index 100% rename from test/sandbox/public/javascripts/controls.js rename to test/active_record_sandbox/public/javascripts/controls.js diff --git a/test/sandbox/public/javascripts/dragdrop.js b/test/active_record_sandbox/public/javascripts/dragdrop.js similarity index 100% rename from test/sandbox/public/javascripts/dragdrop.js rename to test/active_record_sandbox/public/javascripts/dragdrop.js diff --git a/test/sandbox/public/javascripts/effects.js b/test/active_record_sandbox/public/javascripts/effects.js similarity index 100% rename from test/sandbox/public/javascripts/effects.js rename to test/active_record_sandbox/public/javascripts/effects.js diff --git a/test/sandbox/public/javascripts/prototype.js b/test/active_record_sandbox/public/javascripts/prototype.js similarity index 100% rename from test/sandbox/public/javascripts/prototype.js rename to test/active_record_sandbox/public/javascripts/prototype.js diff --git a/test/sandbox/public/javascripts/rails.js b/test/active_record_sandbox/public/javascripts/rails.js similarity index 100% rename from test/sandbox/public/javascripts/rails.js rename to test/active_record_sandbox/public/javascripts/rails.js diff --git a/test/sandbox/public/robots.txt b/test/active_record_sandbox/public/robots.txt similarity index 100% rename from test/sandbox/public/robots.txt rename to test/active_record_sandbox/public/robots.txt diff --git a/test/sandbox/public/stylesheets/.gitkeep b/test/active_record_sandbox/public/stylesheets/.gitkeep similarity index 100% rename from test/sandbox/public/stylesheets/.gitkeep rename to test/active_record_sandbox/public/stylesheets/.gitkeep diff --git a/test/sandbox/script/rails b/test/active_record_sandbox/script/rails similarity index 100% rename from test/sandbox/script/rails rename to test/active_record_sandbox/script/rails diff --git a/test/active_record_sandbox/test/functional/brains_controller_test.rb b/test/active_record_sandbox/test/functional/brains_controller_test.rb new file mode 100644 index 0000000..fc5425d --- /dev/null +++ b/test/active_record_sandbox/test/functional/brains_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class BrainsControllerTest < ActionController::TestCase + test "/error routes to errship's standard error page" do + Errship::Rescuers.expects(:render_404_error).with(ActiveRecord::RecordNotFound, anything) + + get :index + end +end diff --git a/test/sandbox/test/test_helper.rb b/test/active_record_sandbox/test/test_helper.rb similarity index 100% rename from test/sandbox/test/test_helper.rb rename to test/active_record_sandbox/test/test_helper.rb diff --git a/test/sandbox/vendor/plugins/.gitkeep b/test/active_record_sandbox/vendor/plugins/.gitkeep similarity index 100% rename from test/sandbox/vendor/plugins/.gitkeep rename to test/active_record_sandbox/vendor/plugins/.gitkeep diff --git a/test/sandbox/test/functional/brains_controller_test.rb b/test/sandbox/test/functional/brains_controller_test.rb deleted file mode 100644 index ce21a69..0000000 --- a/test/sandbox/test/functional/brains_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class BrainsControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/sandbox/test/unit/helpers/brains_helper_test.rb b/test/sandbox/test/unit/helpers/brains_helper_test.rb deleted file mode 100644 index 6b7647f..0000000 --- a/test/sandbox/test/unit/helpers/brains_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class BrainsHelperTest < ActionView::TestCase -end diff --git a/test/test_helper.rb b/test/test_helper.rb index dc3a8ad..e5f84ad 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -9,6 +9,7 @@ end require 'test/unit' require 'shoulda' +require 'mocha' $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) @@ -16,5 +17,5 @@ # Run the tests for the sandbox (dummy) application ENV['RAILS_ENV'] = 'test' -require 'sandbox/config/environment' +require 'active_record_sandbox/config/environment' require 'rails/test_help' From 73115081c83aed204a747900972800129ae0a35c Mon Sep 17 00:00:00 2001 From: David Czarnecki Date: Fri, 2 Sep 2011 17:30:54 -0400 Subject: [PATCH 2/4] Fixing Mongoid rescuer and actually testing it --- Gemfile | 2 ++ Gemfile.lock | 10 ++++++++++ lib/rescuers/mongoid.rb | 2 +- test/{active_record_sandbox => sandbox}/.gitignore | 0 test/{active_record_sandbox => sandbox}/Gemfile | 2 ++ .../{active_record_sandbox => sandbox}/Gemfile.lock | 0 test/{active_record_sandbox => sandbox}/README | 0 test/{active_record_sandbox => sandbox}/Rakefile | 0 .../app/assets/javascripts/brains.js | 0 .../app/assets/stylesheets/application.css | 0 .../app/assets/stylesheets/brains.css | 0 .../app/controllers/application_controller.rb | 0 .../app/controllers/brains_controller.rb | 2 ++ test/sandbox/app/controllers/zombies_controller.rb | 7 +++++++ .../app/helpers/application_helper.rb | 0 .../app/helpers/brains_helper.rb | 0 .../app/models/user.rb | 0 .../app/views/layouts/application.html.erb | 0 test/{active_record_sandbox => sandbox}/config.ru | 0 .../config/application.rb | 0 .../config/boot.rb | 0 .../config/database.yml | 0 .../config/environment.rb | 0 .../config/environments/development.rb | 0 .../config/environments/production.rb | 0 .../config/environments/test.rb | 0 .../config/initializers/backtrace_silencers.rb | 0 .../config/initializers/inflections.rb | 0 .../config/initializers/mime_types.rb | 0 .../config/initializers/secret_token.rb | 0 .../config/initializers/session_store.rb | 0 .../config/initializers/wrap_parameters.rb | 0 .../config/locales/en.yml | 0 test/sandbox/config/mongoid.yml | 10 ++++++++++ .../config/routes.rb | 1 + .../db/migrate/20110830181342_add_sessions_table.rb | 0 .../{active_record_sandbox => sandbox}/db/schema.rb | 0 test/{active_record_sandbox => sandbox}/db/seeds.rb | 0 .../lib/tasks/.gitkeep | 0 .../public/404.html | 0 .../public/422.html | 0 .../public/500.html | 0 .../public/favicon.ico | 0 .../public/images/rails.png | Bin .../public/javascripts/application.js | 0 .../public/javascripts/controls.js | 0 .../public/javascripts/dragdrop.js | 0 .../public/javascripts/effects.js | 0 .../public/javascripts/prototype.js | 0 .../public/javascripts/rails.js | 0 .../public/robots.txt | 0 .../public/stylesheets/.gitkeep | 0 .../{active_record_sandbox => sandbox}/script/rails | 0 .../test/functional/brains_controller_test.rb | 0 .../test/functional/zombies_controller_test.rb | 9 +++++++++ .../test/test_helper.rb | 0 .../vendor/plugins/.gitkeep | 0 test/test_helper.rb | 2 +- 58 files changed, 45 insertions(+), 2 deletions(-) rename test/{active_record_sandbox => sandbox}/.gitignore (100%) rename test/{active_record_sandbox => sandbox}/Gemfile (94%) rename test/{active_record_sandbox => sandbox}/Gemfile.lock (100%) rename test/{active_record_sandbox => sandbox}/README (100%) rename test/{active_record_sandbox => sandbox}/Rakefile (100%) rename test/{active_record_sandbox => sandbox}/app/assets/javascripts/brains.js (100%) rename test/{active_record_sandbox => sandbox}/app/assets/stylesheets/application.css (100%) rename test/{active_record_sandbox => sandbox}/app/assets/stylesheets/brains.css (100%) rename test/{active_record_sandbox => sandbox}/app/controllers/application_controller.rb (100%) rename test/{active_record_sandbox => sandbox}/app/controllers/brains_controller.rb (70%) create mode 100644 test/sandbox/app/controllers/zombies_controller.rb rename test/{active_record_sandbox => sandbox}/app/helpers/application_helper.rb (100%) rename test/{active_record_sandbox => sandbox}/app/helpers/brains_helper.rb (100%) rename test/{active_record_sandbox => sandbox}/app/models/user.rb (100%) rename test/{active_record_sandbox => sandbox}/app/views/layouts/application.html.erb (100%) rename test/{active_record_sandbox => sandbox}/config.ru (100%) rename test/{active_record_sandbox => sandbox}/config/application.rb (100%) rename test/{active_record_sandbox => sandbox}/config/boot.rb (100%) rename test/{active_record_sandbox => sandbox}/config/database.yml (100%) rename test/{active_record_sandbox => sandbox}/config/environment.rb (100%) rename test/{active_record_sandbox => sandbox}/config/environments/development.rb (100%) rename test/{active_record_sandbox => sandbox}/config/environments/production.rb (100%) rename test/{active_record_sandbox => sandbox}/config/environments/test.rb (100%) rename test/{active_record_sandbox => sandbox}/config/initializers/backtrace_silencers.rb (100%) rename test/{active_record_sandbox => sandbox}/config/initializers/inflections.rb (100%) rename test/{active_record_sandbox => sandbox}/config/initializers/mime_types.rb (100%) rename test/{active_record_sandbox => sandbox}/config/initializers/secret_token.rb (100%) rename test/{active_record_sandbox => sandbox}/config/initializers/session_store.rb (100%) rename test/{active_record_sandbox => sandbox}/config/initializers/wrap_parameters.rb (100%) rename test/{active_record_sandbox => sandbox}/config/locales/en.yml (100%) create mode 100644 test/sandbox/config/mongoid.yml rename test/{active_record_sandbox => sandbox}/config/routes.rb (74%) rename test/{active_record_sandbox => sandbox}/db/migrate/20110830181342_add_sessions_table.rb (100%) rename test/{active_record_sandbox => sandbox}/db/schema.rb (100%) rename test/{active_record_sandbox => sandbox}/db/seeds.rb (100%) rename test/{active_record_sandbox => sandbox}/lib/tasks/.gitkeep (100%) rename test/{active_record_sandbox => sandbox}/public/404.html (100%) rename test/{active_record_sandbox => sandbox}/public/422.html (100%) rename test/{active_record_sandbox => sandbox}/public/500.html (100%) rename test/{active_record_sandbox => sandbox}/public/favicon.ico (100%) rename test/{active_record_sandbox => sandbox}/public/images/rails.png (100%) rename test/{active_record_sandbox => sandbox}/public/javascripts/application.js (100%) rename test/{active_record_sandbox => sandbox}/public/javascripts/controls.js (100%) rename test/{active_record_sandbox => sandbox}/public/javascripts/dragdrop.js (100%) rename test/{active_record_sandbox => sandbox}/public/javascripts/effects.js (100%) rename test/{active_record_sandbox => sandbox}/public/javascripts/prototype.js (100%) rename test/{active_record_sandbox => sandbox}/public/javascripts/rails.js (100%) rename test/{active_record_sandbox => sandbox}/public/robots.txt (100%) rename test/{active_record_sandbox => sandbox}/public/stylesheets/.gitkeep (100%) rename test/{active_record_sandbox => sandbox}/script/rails (100%) rename test/{active_record_sandbox => sandbox}/test/functional/brains_controller_test.rb (100%) create mode 100644 test/sandbox/test/functional/zombies_controller_test.rb rename test/{active_record_sandbox => sandbox}/test/test_helper.rb (100%) rename test/{active_record_sandbox => sandbox}/vendor/plugins/.gitkeep (100%) diff --git a/Gemfile b/Gemfile index 475d383..78362f5 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,8 @@ group :test do gem 'sqlite3-ruby' gem 'turn' gem 'mocha', :require => false + gem 'bson_ext' + gem 'mongoid', '>= 2.0.0.beta.19' end gem 'haml' diff --git a/Gemfile.lock b/Gemfile.lock index f954119..a2367aa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -33,6 +33,8 @@ GEM ansi (1.2.5) arel (2.2.1) bcrypt-ruby (3.0.0) + bson (1.3.1) + bson_ext (1.3.1) builder (3.0.0) erubis (2.7.0) git (1.2.5) @@ -49,6 +51,12 @@ GEM treetop (~> 1.4.8) mime-types (1.16) mocha (0.9.12) + mongo (1.3.1) + bson (>= 1.3.1) + mongoid (2.2.0) + activemodel (~> 3.0) + mongo (~> 1.3) + tzinfo (~> 0.3.22) multi_json (1.0.3) polyglot (0.3.2) rack (1.3.2) @@ -99,10 +107,12 @@ PLATFORMS ruby DEPENDENCIES + bson_ext bundler (~> 1.0.0) haml jeweler (~> 1.6.0) mocha + mongoid (>= 2.0.0.beta.19) rails (= 3.1.0) rake (= 0.8.7) rcov diff --git a/lib/rescuers/mongoid.rb b/lib/rescuers/mongoid.rb index d121ffd..0b2c74a 100644 --- a/lib/rescuers/mongoid.rb +++ b/lib/rescuers/mongoid.rb @@ -3,7 +3,7 @@ module Mongoid module Rescuers def self.included(base) unless Rails.application.config.consider_all_requests_local - base.rescue_from ::Mongoid::DocumentNotFound, :with => :render_404_error + base.rescue_from ::Mongoid::Errors::DocumentNotFound, :with => :render_404_error end end end diff --git a/test/active_record_sandbox/.gitignore b/test/sandbox/.gitignore similarity index 100% rename from test/active_record_sandbox/.gitignore rename to test/sandbox/.gitignore diff --git a/test/active_record_sandbox/Gemfile b/test/sandbox/Gemfile similarity index 94% rename from test/active_record_sandbox/Gemfile rename to test/sandbox/Gemfile index 34ba0df..d6d847f 100644 --- a/test/active_record_sandbox/Gemfile +++ b/test/sandbox/Gemfile @@ -8,6 +8,8 @@ gem 'airbrake' # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3-ruby' +gem 'bson_ext' +gem 'mongoid', '>= 2.0.0.beta.19' # Use unicorn as the web server # gem 'unicorn' diff --git a/test/active_record_sandbox/Gemfile.lock b/test/sandbox/Gemfile.lock similarity index 100% rename from test/active_record_sandbox/Gemfile.lock rename to test/sandbox/Gemfile.lock diff --git a/test/active_record_sandbox/README b/test/sandbox/README similarity index 100% rename from test/active_record_sandbox/README rename to test/sandbox/README diff --git a/test/active_record_sandbox/Rakefile b/test/sandbox/Rakefile similarity index 100% rename from test/active_record_sandbox/Rakefile rename to test/sandbox/Rakefile diff --git a/test/active_record_sandbox/app/assets/javascripts/brains.js b/test/sandbox/app/assets/javascripts/brains.js similarity index 100% rename from test/active_record_sandbox/app/assets/javascripts/brains.js rename to test/sandbox/app/assets/javascripts/brains.js diff --git a/test/active_record_sandbox/app/assets/stylesheets/application.css b/test/sandbox/app/assets/stylesheets/application.css similarity index 100% rename from test/active_record_sandbox/app/assets/stylesheets/application.css rename to test/sandbox/app/assets/stylesheets/application.css diff --git a/test/active_record_sandbox/app/assets/stylesheets/brains.css b/test/sandbox/app/assets/stylesheets/brains.css similarity index 100% rename from test/active_record_sandbox/app/assets/stylesheets/brains.css rename to test/sandbox/app/assets/stylesheets/brains.css diff --git a/test/active_record_sandbox/app/controllers/application_controller.rb b/test/sandbox/app/controllers/application_controller.rb similarity index 100% rename from test/active_record_sandbox/app/controllers/application_controller.rb rename to test/sandbox/app/controllers/application_controller.rb diff --git a/test/active_record_sandbox/app/controllers/brains_controller.rb b/test/sandbox/app/controllers/brains_controller.rb similarity index 70% rename from test/active_record_sandbox/app/controllers/brains_controller.rb rename to test/sandbox/app/controllers/brains_controller.rb index 9876a62..e32f4b5 100644 --- a/test/active_record_sandbox/app/controllers/brains_controller.rb +++ b/test/sandbox/app/controllers/brains_controller.rb @@ -1,4 +1,6 @@ class BrainsController < ApplicationController + include Errship::ActiveRecord::Rescuers + def index raise ActiveRecord::RecordNotFound end diff --git a/test/sandbox/app/controllers/zombies_controller.rb b/test/sandbox/app/controllers/zombies_controller.rb new file mode 100644 index 0000000..655da14 --- /dev/null +++ b/test/sandbox/app/controllers/zombies_controller.rb @@ -0,0 +1,7 @@ +class ZombiesController < ApplicationController + include Errship::Mongoid::Rescuers + + def index + raise Mongoid::Errors::DocumentNotFound + end +end diff --git a/test/active_record_sandbox/app/helpers/application_helper.rb b/test/sandbox/app/helpers/application_helper.rb similarity index 100% rename from test/active_record_sandbox/app/helpers/application_helper.rb rename to test/sandbox/app/helpers/application_helper.rb diff --git a/test/active_record_sandbox/app/helpers/brains_helper.rb b/test/sandbox/app/helpers/brains_helper.rb similarity index 100% rename from test/active_record_sandbox/app/helpers/brains_helper.rb rename to test/sandbox/app/helpers/brains_helper.rb diff --git a/test/active_record_sandbox/app/models/user.rb b/test/sandbox/app/models/user.rb similarity index 100% rename from test/active_record_sandbox/app/models/user.rb rename to test/sandbox/app/models/user.rb diff --git a/test/active_record_sandbox/app/views/layouts/application.html.erb b/test/sandbox/app/views/layouts/application.html.erb similarity index 100% rename from test/active_record_sandbox/app/views/layouts/application.html.erb rename to test/sandbox/app/views/layouts/application.html.erb diff --git a/test/active_record_sandbox/config.ru b/test/sandbox/config.ru similarity index 100% rename from test/active_record_sandbox/config.ru rename to test/sandbox/config.ru diff --git a/test/active_record_sandbox/config/application.rb b/test/sandbox/config/application.rb similarity index 100% rename from test/active_record_sandbox/config/application.rb rename to test/sandbox/config/application.rb diff --git a/test/active_record_sandbox/config/boot.rb b/test/sandbox/config/boot.rb similarity index 100% rename from test/active_record_sandbox/config/boot.rb rename to test/sandbox/config/boot.rb diff --git a/test/active_record_sandbox/config/database.yml b/test/sandbox/config/database.yml similarity index 100% rename from test/active_record_sandbox/config/database.yml rename to test/sandbox/config/database.yml diff --git a/test/active_record_sandbox/config/environment.rb b/test/sandbox/config/environment.rb similarity index 100% rename from test/active_record_sandbox/config/environment.rb rename to test/sandbox/config/environment.rb diff --git a/test/active_record_sandbox/config/environments/development.rb b/test/sandbox/config/environments/development.rb similarity index 100% rename from test/active_record_sandbox/config/environments/development.rb rename to test/sandbox/config/environments/development.rb diff --git a/test/active_record_sandbox/config/environments/production.rb b/test/sandbox/config/environments/production.rb similarity index 100% rename from test/active_record_sandbox/config/environments/production.rb rename to test/sandbox/config/environments/production.rb diff --git a/test/active_record_sandbox/config/environments/test.rb b/test/sandbox/config/environments/test.rb similarity index 100% rename from test/active_record_sandbox/config/environments/test.rb rename to test/sandbox/config/environments/test.rb diff --git a/test/active_record_sandbox/config/initializers/backtrace_silencers.rb b/test/sandbox/config/initializers/backtrace_silencers.rb similarity index 100% rename from test/active_record_sandbox/config/initializers/backtrace_silencers.rb rename to test/sandbox/config/initializers/backtrace_silencers.rb diff --git a/test/active_record_sandbox/config/initializers/inflections.rb b/test/sandbox/config/initializers/inflections.rb similarity index 100% rename from test/active_record_sandbox/config/initializers/inflections.rb rename to test/sandbox/config/initializers/inflections.rb diff --git a/test/active_record_sandbox/config/initializers/mime_types.rb b/test/sandbox/config/initializers/mime_types.rb similarity index 100% rename from test/active_record_sandbox/config/initializers/mime_types.rb rename to test/sandbox/config/initializers/mime_types.rb diff --git a/test/active_record_sandbox/config/initializers/secret_token.rb b/test/sandbox/config/initializers/secret_token.rb similarity index 100% rename from test/active_record_sandbox/config/initializers/secret_token.rb rename to test/sandbox/config/initializers/secret_token.rb diff --git a/test/active_record_sandbox/config/initializers/session_store.rb b/test/sandbox/config/initializers/session_store.rb similarity index 100% rename from test/active_record_sandbox/config/initializers/session_store.rb rename to test/sandbox/config/initializers/session_store.rb diff --git a/test/active_record_sandbox/config/initializers/wrap_parameters.rb b/test/sandbox/config/initializers/wrap_parameters.rb similarity index 100% rename from test/active_record_sandbox/config/initializers/wrap_parameters.rb rename to test/sandbox/config/initializers/wrap_parameters.rb diff --git a/test/active_record_sandbox/config/locales/en.yml b/test/sandbox/config/locales/en.yml similarity index 100% rename from test/active_record_sandbox/config/locales/en.yml rename to test/sandbox/config/locales/en.yml diff --git a/test/sandbox/config/mongoid.yml b/test/sandbox/config/mongoid.yml new file mode 100644 index 0000000..738b0ff --- /dev/null +++ b/test/sandbox/config/mongoid.yml @@ -0,0 +1,10 @@ +defaults: &defaults + host: localhost + +development: + <<: *defaults + database: mongoid_sandbox_development + +test: + <<: *defaults + database: mongoid_sandbox_test \ No newline at end of file diff --git a/test/active_record_sandbox/config/routes.rb b/test/sandbox/config/routes.rb similarity index 74% rename from test/active_record_sandbox/config/routes.rb rename to test/sandbox/config/routes.rb index 0b49f02..c19d643 100644 --- a/test/active_record_sandbox/config/routes.rb +++ b/test/sandbox/config/routes.rb @@ -1,4 +1,5 @@ Sandbox::Application.routes.draw do match '/try_flashback', :controller => 'application', :action => 'try_flashback' match '/brains', :controller => 'brains', :action => 'index' + match '/zombies', :controller => 'zombies', :action => 'index' end diff --git a/test/active_record_sandbox/db/migrate/20110830181342_add_sessions_table.rb b/test/sandbox/db/migrate/20110830181342_add_sessions_table.rb similarity index 100% rename from test/active_record_sandbox/db/migrate/20110830181342_add_sessions_table.rb rename to test/sandbox/db/migrate/20110830181342_add_sessions_table.rb diff --git a/test/active_record_sandbox/db/schema.rb b/test/sandbox/db/schema.rb similarity index 100% rename from test/active_record_sandbox/db/schema.rb rename to test/sandbox/db/schema.rb diff --git a/test/active_record_sandbox/db/seeds.rb b/test/sandbox/db/seeds.rb similarity index 100% rename from test/active_record_sandbox/db/seeds.rb rename to test/sandbox/db/seeds.rb diff --git a/test/active_record_sandbox/lib/tasks/.gitkeep b/test/sandbox/lib/tasks/.gitkeep similarity index 100% rename from test/active_record_sandbox/lib/tasks/.gitkeep rename to test/sandbox/lib/tasks/.gitkeep diff --git a/test/active_record_sandbox/public/404.html b/test/sandbox/public/404.html similarity index 100% rename from test/active_record_sandbox/public/404.html rename to test/sandbox/public/404.html diff --git a/test/active_record_sandbox/public/422.html b/test/sandbox/public/422.html similarity index 100% rename from test/active_record_sandbox/public/422.html rename to test/sandbox/public/422.html diff --git a/test/active_record_sandbox/public/500.html b/test/sandbox/public/500.html similarity index 100% rename from test/active_record_sandbox/public/500.html rename to test/sandbox/public/500.html diff --git a/test/active_record_sandbox/public/favicon.ico b/test/sandbox/public/favicon.ico similarity index 100% rename from test/active_record_sandbox/public/favicon.ico rename to test/sandbox/public/favicon.ico diff --git a/test/active_record_sandbox/public/images/rails.png b/test/sandbox/public/images/rails.png similarity index 100% rename from test/active_record_sandbox/public/images/rails.png rename to test/sandbox/public/images/rails.png diff --git a/test/active_record_sandbox/public/javascripts/application.js b/test/sandbox/public/javascripts/application.js similarity index 100% rename from test/active_record_sandbox/public/javascripts/application.js rename to test/sandbox/public/javascripts/application.js diff --git a/test/active_record_sandbox/public/javascripts/controls.js b/test/sandbox/public/javascripts/controls.js similarity index 100% rename from test/active_record_sandbox/public/javascripts/controls.js rename to test/sandbox/public/javascripts/controls.js diff --git a/test/active_record_sandbox/public/javascripts/dragdrop.js b/test/sandbox/public/javascripts/dragdrop.js similarity index 100% rename from test/active_record_sandbox/public/javascripts/dragdrop.js rename to test/sandbox/public/javascripts/dragdrop.js diff --git a/test/active_record_sandbox/public/javascripts/effects.js b/test/sandbox/public/javascripts/effects.js similarity index 100% rename from test/active_record_sandbox/public/javascripts/effects.js rename to test/sandbox/public/javascripts/effects.js diff --git a/test/active_record_sandbox/public/javascripts/prototype.js b/test/sandbox/public/javascripts/prototype.js similarity index 100% rename from test/active_record_sandbox/public/javascripts/prototype.js rename to test/sandbox/public/javascripts/prototype.js diff --git a/test/active_record_sandbox/public/javascripts/rails.js b/test/sandbox/public/javascripts/rails.js similarity index 100% rename from test/active_record_sandbox/public/javascripts/rails.js rename to test/sandbox/public/javascripts/rails.js diff --git a/test/active_record_sandbox/public/robots.txt b/test/sandbox/public/robots.txt similarity index 100% rename from test/active_record_sandbox/public/robots.txt rename to test/sandbox/public/robots.txt diff --git a/test/active_record_sandbox/public/stylesheets/.gitkeep b/test/sandbox/public/stylesheets/.gitkeep similarity index 100% rename from test/active_record_sandbox/public/stylesheets/.gitkeep rename to test/sandbox/public/stylesheets/.gitkeep diff --git a/test/active_record_sandbox/script/rails b/test/sandbox/script/rails similarity index 100% rename from test/active_record_sandbox/script/rails rename to test/sandbox/script/rails diff --git a/test/active_record_sandbox/test/functional/brains_controller_test.rb b/test/sandbox/test/functional/brains_controller_test.rb similarity index 100% rename from test/active_record_sandbox/test/functional/brains_controller_test.rb rename to test/sandbox/test/functional/brains_controller_test.rb diff --git a/test/sandbox/test/functional/zombies_controller_test.rb b/test/sandbox/test/functional/zombies_controller_test.rb new file mode 100644 index 0000000..cc7b121 --- /dev/null +++ b/test/sandbox/test/functional/zombies_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class ZombiesControllerTest < ActionController::TestCase + test "/error routes to errship's standard error page" do + Errship::Rescuers.expects(:render_404_error).with(Mongoid::Errors::DocumentNotFound, anything) + + get :index + end +end diff --git a/test/active_record_sandbox/test/test_helper.rb b/test/sandbox/test/test_helper.rb similarity index 100% rename from test/active_record_sandbox/test/test_helper.rb rename to test/sandbox/test/test_helper.rb diff --git a/test/active_record_sandbox/vendor/plugins/.gitkeep b/test/sandbox/vendor/plugins/.gitkeep similarity index 100% rename from test/active_record_sandbox/vendor/plugins/.gitkeep rename to test/sandbox/vendor/plugins/.gitkeep diff --git a/test/test_helper.rb b/test/test_helper.rb index e5f84ad..4564a98 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -17,5 +17,5 @@ # Run the tests for the sandbox (dummy) application ENV['RAILS_ENV'] = 'test' -require 'active_record_sandbox/config/environment' +require 'sandbox/config/environment' require 'rails/test_help' From 60e36803f3924a36492071d2304e478dc6926f37 Mon Sep 17 00:00:00 2001 From: David Czarnecki Date: Fri, 2 Sep 2011 17:36:37 -0400 Subject: [PATCH 3/4] Test that errship actually gets the MongoMapper::DocumentNotFound exception --- Gemfile | 3 ++- Gemfile.lock | 9 ++++++++- test/sandbox/Gemfile | 3 ++- test/sandbox/app/controllers/humans_controller.rb | 7 +++++++ test/sandbox/config/routes.rb | 1 + test/sandbox/test/functional/brains_controller_test.rb | 2 +- test/sandbox/test/functional/humans_controller_test.rb | 9 +++++++++ test/sandbox/test/functional/zombies_controller_test.rb | 2 +- 8 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 test/sandbox/app/controllers/humans_controller.rb create mode 100644 test/sandbox/test/functional/humans_controller_test.rb diff --git a/Gemfile b/Gemfile index 78362f5..38f19bc 100644 --- a/Gemfile +++ b/Gemfile @@ -18,8 +18,9 @@ group :test do gem 'sqlite3-ruby' gem 'turn' gem 'mocha', :require => false + gem 'mongoid' + gem 'mongo_mapper' gem 'bson_ext' - gem 'mongoid', '>= 2.0.0.beta.19' end gem 'haml' diff --git a/Gemfile.lock b/Gemfile.lock index a2367aa..85e0960 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,11 +53,17 @@ GEM mocha (0.9.12) mongo (1.3.1) bson (>= 1.3.1) + mongo_mapper (0.9.2) + activemodel (~> 3.0) + activesupport (~> 3.0) + plucky (~> 0.3.8) mongoid (2.2.0) activemodel (~> 3.0) mongo (~> 1.3) tzinfo (~> 0.3.22) multi_json (1.0.3) + plucky (0.3.8) + mongo (~> 1.3) polyglot (0.3.2) rack (1.3.2) rack-cache (1.0.3) @@ -112,7 +118,8 @@ DEPENDENCIES haml jeweler (~> 1.6.0) mocha - mongoid (>= 2.0.0.beta.19) + mongo_mapper + mongoid rails (= 3.1.0) rake (= 0.8.7) rcov diff --git a/test/sandbox/Gemfile b/test/sandbox/Gemfile index d6d847f..fbe7eb9 100644 --- a/test/sandbox/Gemfile +++ b/test/sandbox/Gemfile @@ -8,8 +8,9 @@ gem 'airbrake' # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3-ruby' +gem 'mongoid' +gem 'mongo_mapper' gem 'bson_ext' -gem 'mongoid', '>= 2.0.0.beta.19' # Use unicorn as the web server # gem 'unicorn' diff --git a/test/sandbox/app/controllers/humans_controller.rb b/test/sandbox/app/controllers/humans_controller.rb new file mode 100644 index 0000000..45eca3c --- /dev/null +++ b/test/sandbox/app/controllers/humans_controller.rb @@ -0,0 +1,7 @@ +class HumansController < ApplicationController + include Errship::MongoMapper::Rescuers + + def index + raise MongoMapper::DocumentNotFound + end +end diff --git a/test/sandbox/config/routes.rb b/test/sandbox/config/routes.rb index c19d643..c815b1f 100644 --- a/test/sandbox/config/routes.rb +++ b/test/sandbox/config/routes.rb @@ -2,4 +2,5 @@ match '/try_flashback', :controller => 'application', :action => 'try_flashback' match '/brains', :controller => 'brains', :action => 'index' match '/zombies', :controller => 'zombies', :action => 'index' + match '/humans', :controller => 'humans', :action => 'index' end diff --git a/test/sandbox/test/functional/brains_controller_test.rb b/test/sandbox/test/functional/brains_controller_test.rb index fc5425d..277389d 100644 --- a/test/sandbox/test/functional/brains_controller_test.rb +++ b/test/sandbox/test/functional/brains_controller_test.rb @@ -1,7 +1,7 @@ require 'test_helper' class BrainsControllerTest < ActionController::TestCase - test "/error routes to errship's standard error page" do + test "/error routes to errship's standard error page with ActiveRecord::RecordNotFound" do Errship::Rescuers.expects(:render_404_error).with(ActiveRecord::RecordNotFound, anything) get :index diff --git a/test/sandbox/test/functional/humans_controller_test.rb b/test/sandbox/test/functional/humans_controller_test.rb new file mode 100644 index 0000000..3d58b5b --- /dev/null +++ b/test/sandbox/test/functional/humans_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class HumansControllerTest < ActionController::TestCase + test "/error routes to errship's standard error page with MongoMapper::DocumentNotFound exception" do + Errship::Rescuers.expects(:render_404_error).with(MongoMapper::DocumentNotFound, anything) + + get :index + end +end diff --git a/test/sandbox/test/functional/zombies_controller_test.rb b/test/sandbox/test/functional/zombies_controller_test.rb index cc7b121..1e026b7 100644 --- a/test/sandbox/test/functional/zombies_controller_test.rb +++ b/test/sandbox/test/functional/zombies_controller_test.rb @@ -1,7 +1,7 @@ require 'test_helper' class ZombiesControllerTest < ActionController::TestCase - test "/error routes to errship's standard error page" do + test "/error routes to errship's standard error page with Mongoid::Errors::DocumentNotFound" do Errship::Rescuers.expects(:render_404_error).with(Mongoid::Errors::DocumentNotFound, anything) get :index From 1d85404408dc26dd396a83456f87e186ad633681 Mon Sep 17 00:00:00 2001 From: David Czarnecki Date: Fri, 2 Sep 2011 17:40:58 -0400 Subject: [PATCH 4/4] Version bump because of Mongoid error fix. Updating README. Updating gemspec with authors and e-mails. --- README.rdoc | 4 ++++ Rakefile | 4 ++-- VERSION | 2 +- errship.gemspec | 12 ++++++------ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.rdoc b/README.rdoc index ac2b68a..8f1abfa 100644 --- a/README.rdoc +++ b/README.rdoc @@ -90,6 +90,10 @@ The following methods are provided: If Airbrake is installed, every rescuer will report the exception, except for 404. == Changelog +2.0.1 + - Added tests for ActiveRecord, Mongoid and MongoMapper rescuers + - Fixed Mongoid module + 2.0.0 - Breaks out ORM error handling into submodules. Not backwards compatible. diff --git a/Rakefile b/Rakefile index 903ac53..807216e 100644 --- a/Rakefile +++ b/Rakefile @@ -19,8 +19,8 @@ Jeweler::Tasks.new do |gem| gem.license = "MIT" gem.summary = %Q{Errship is a Rails 3.1 engine for rendering error pages inside your layout.} gem.description = %Q{Errship is a Rails 3.1 engine for rendering error pages inside your layout. It supports i18n, custom exceptions, and Airbrake (Hoptoad) error tracking.} - gem.email = "lkoester@agoragames.com" - gem.authors = ["Logan Koester"] + gem.email = ["lkoester@agoragames.com", "mwilson@agoragames.com", "dczarnecki@agoragames.com"] + gem.authors = ["Logan Koester", "Matthew Wilson", "David Czarnecki"] gem.files = Dir["{lib}/**/*", "{app}/**/*", "{config}/**/*", "{public}/**/*"] # dependencies defined in Gemfile end diff --git a/VERSION b/VERSION index 359a5b9..10bf840 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0 \ No newline at end of file +2.0.1 \ No newline at end of file diff --git a/errship.gemspec b/errship.gemspec index abc1e88..ce921e7 100644 --- a/errship.gemspec +++ b/errship.gemspec @@ -5,13 +5,13 @@ Gem::Specification.new do |s| s.name = %q{errship} - s.version = "2.0.0" + s.version = "2.0.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Logan Koester"] + s.authors = [%q{Logan Koester}, %q{Matthew Wilson}, %q{David Czarnecki}] s.date = %q{2011-09-02} s.description = %q{Errship is a Rails 3.1 engine for rendering error pages inside your layout. It supports i18n, custom exceptions, and Airbrake (Hoptoad) error tracking.} - s.email = %q{lkoester@agoragames.com} + s.email = [%q{lkoester@agoragames.com}, %q{mwilson@agoragames.com}, %q{dczarnecki@agoragames.com}] s.extra_rdoc_files = [ "LICENSE.txt", "README.rdoc" @@ -28,9 +28,9 @@ Gem::Specification.new do |s| "lib/rescuers/mongoid.rb" ] s.homepage = %q{http://github.com/logankoester/errship} - s.licenses = ["MIT"] - s.require_paths = ["lib"] - s.rubygems_version = %q{1.6.2} + s.licenses = [%q{MIT}] + s.require_paths = [%q{lib}] + s.rubygems_version = %q{1.8.6} s.summary = %q{Errship is a Rails 3.1 engine for rendering error pages inside your layout.} if s.respond_to? :specification_version then