Skip to content

Commit

Permalink
Merge pull request #2 from agoragames/updated_functional_tests
Browse files Browse the repository at this point in the history
Updated functional tests, fix for Mongoid module, version bump
  • Loading branch information
hypomodern committed Sep 2, 2011
2 parents 0ef4e2a + 1d85404 commit 2e5c7d1
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 19 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ group :test do
gem 'rails', '3.1.0'
gem 'sqlite3-ruby'
gem 'turn'
gem 'mocha', :require => false
gem 'mongoid'
gem 'mongo_mapper'
gem 'bson_ext'
end

gem 'haml'
19 changes: 19 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -48,7 +50,20 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
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)
Expand Down Expand Up @@ -98,9 +113,13 @@ PLATFORMS
ruby

DEPENDENCIES
bson_ext
bundler (~> 1.0.0)
haml
jeweler (~> 1.6.0)
mocha
mongo_mapper
mongoid
rails (= 3.1.0)
rake (= 0.8.7)
rcov
Expand Down
4 changes: 4 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
gem.authors = ["Logan Koester"]
gem.email = ["[email protected]", "[email protected]", "[email protected]"]
gem.authors = ["Logan Koester", "Matthew Wilson", "David Czarnecki"]
gem.files = Dir["{lib}/**/*", "{app}/**/*", "{config}/**/*", "{public}/**/*"]
# dependencies defined in Gemfile
end
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.0.1
12 changes: 6 additions & 6 deletions errship.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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{[email protected]}
s.email = [%q{[email protected]}, %q{[email protected]}, %q{[email protected]}]
s.extra_rdoc_files = [
"LICENSE.txt",
"README.rdoc"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rescuers/mongoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/sandbox/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ gem 'airbrake'
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3-ruby'
gem 'mongoid'
gem 'mongo_mapper'
gem 'bson_ext'

# Use unicorn as the web server
# gem 'unicorn'
Expand Down
4 changes: 2 additions & 2 deletions test/sandbox/app/controllers/brains_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class BrainsController < ApplicationController
rescue_from ActiveRecord::RecordNotFound, :with => ->(e){ render_404_error e, 'brainless' }

include Errship::ActiveRecord::Rescuers
def index
raise ActiveRecord::RecordNotFound
end
Expand Down
7 changes: 7 additions & 0 deletions test/sandbox/app/controllers/humans_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class HumansController < ApplicationController
include Errship::MongoMapper::Rescuers

def index
raise MongoMapper::DocumentNotFound
end
end
7 changes: 7 additions & 0 deletions test/sandbox/app/controllers/zombies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ZombiesController < ApplicationController
include Errship::Mongoid::Rescuers

def index
raise Mongoid::Errors::DocumentNotFound
end
end
2 changes: 2 additions & 0 deletions test/sandbox/app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class User < ActiveRecord::Base
end
10 changes: 10 additions & 0 deletions test/sandbox/config/mongoid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
defaults: &defaults
host: localhost

development:
<<: *defaults
database: mongoid_sandbox_development

test:
<<: *defaults
database: mongoid_sandbox_test
2 changes: 2 additions & 0 deletions test/sandbox/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
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'
match '/humans', :controller => 'humans', :action => 'index'
end
8 changes: 5 additions & 3 deletions test/sandbox/test/functional/brains_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require 'test_helper'

class BrainsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
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
end
end
9 changes: 9 additions & 0 deletions test/sandbox/test/functional/humans_controller_test.rb
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions test/sandbox/test/functional/zombies_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'test_helper'

class ZombiesControllerTest < ActionController::TestCase
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
end
end
4 changes: 0 additions & 4 deletions test/sandbox/test/unit/helpers/brains_helper_test.rb

This file was deleted.

1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down

0 comments on commit 2e5c7d1

Please sign in to comment.