Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make rake_test pass

  • Loading branch information...
commit 31a68c1fc7f62ae1ea98c13b357c41b507260712 1 parent 82251e6
@rafaelfranca rafaelfranca authored
View
2  lib/rails-observers.rb
@@ -4,7 +4,7 @@
module Rails
module Observers
class Railtie < ::Rails::Railtie
- initializer "active_record.observer" do
+ initializer "active_record.observer", :before => "active_record.set_configs" do
ActiveSupport.on_load(:active_record) do
require "rails/observers/activerecord/active_record"
end
View
2  lib/rails/generators/active_record/observer/observer_generator.rb
@@ -5,6 +5,8 @@ module Generators
class ObserverGenerator < Base
check_class_collision :suffix => "Observer"
+ source_root File.expand_path("../templates", __FILE__)
+
def create_observer_file
template 'observer.rb', File.join('app/models', class_path, "#{file_name}_observer.rb")
end
View
17 lib/rails/generators/active_record/observer/templates/observer.rb
@@ -1,15 +1,4 @@
-require 'rails/generators/active_record'
-
-module ActiveRecord
- module Generators
- class ObserverGenerator < Base
- check_class_collision :suffix => "Observer"
-
- def create_observer_file
- template 'observer.rb', File.join('app/models', class_path, "#{file_name}_observer.rb")
- end
-
- hook_for :test_framework
- end
- end
+<% module_namespacing do -%>
+class <%= class_name %>Observer < ActiveRecord::Observer
end
+<% end -%>
View
2  lib/rails/generators/test_unit/observer/observer_generator.rb
@@ -5,6 +5,8 @@ module Generators
class ObserverGenerator < Base
check_class_collision :suffix => "ObserverTest"
+ source_root File.expand_path("../templates", __FILE__)
+
def create_test_files
template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_observer_test.rb")
end
View
5 test/rake_test.rb
@@ -1,3 +1,6 @@
+require 'isolation/abstract_unit'
+require 'rails-observers'
+
module ApplicationTests
class RakeTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Isolation
@@ -11,7 +14,7 @@ def setup
def teardown
teardown_app
end
-
+
def test_load_activerecord_base_when_we_use_observers
Dir.chdir(app_path) do
`bundle exec rails g model user;
Please sign in to comment.
Something went wrong with that request. Please try again.