diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/abstract_unit.rb | 4 | ||||
-rw-r--r-- | railties/test/application/notifications_test.rb | 28 | ||||
-rw-r--r-- | railties/test/plugins/framework_extension_test.rb | 5 |
3 files changed, 26 insertions, 11 deletions
diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 47013d7797..66ab5a08c3 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -22,6 +22,8 @@ require 'active_support/test_case' require 'action_controller' require 'rails' -Rails::Initializer.run do |config| +# TODO: Remove these hacks +class TestApp < Rails::Application config.root = File.dirname(__FILE__) end +Rails.application = TestApp diff --git a/railties/test/application/notifications_test.rb b/railties/test/application/notifications_test.rb index 71e406f2c1..8229e83147 100644 --- a/railties/test/application/notifications_test.rb +++ b/railties/test/application/notifications_test.rb @@ -1,27 +1,35 @@ require "isolation/abstract_unit" module ApplicationTests - class NotificationsTest < Test::Unit::TestCase - include ActiveSupport::Testing::Isolation + class MyQueue + def publish(name, *args) + raise name + end - class MyQueue - def publish(name, *args) - raise name - end + # Not a full queue implementation + def method_missing(name, *args, &blk) + self end + end + + class NotificationsTest < Test::Unit::TestCase + include ActiveSupport::Testing::Isolation def setup build_app boot_rails - require "rails" require "active_support/notifications" @events = [] - Rails::Initializer.run do |c| - c.notifications.notifier = ActiveSupport::Notifications::Notifier.new(MyQueue.new) - end + + add_to_config <<-RUBY + config.notifications.notifier = ActiveSupport::Notifications::Notifier.new(ApplicationTests::MyQueue.new) + RUBY end test "new queue is set" do + use_frameworks [] + require "#{app_path}/config/environment" + assert_raise RuntimeError do ActiveSupport::Notifications.publish('foo') end diff --git a/railties/test/plugins/framework_extension_test.rb b/railties/test/plugins/framework_extension_test.rb index 5e4ecf30dd..a6c7b753f8 100644 --- a/railties/test/plugins/framework_extension_test.rb +++ b/railties/test/plugins/framework_extension_test.rb @@ -2,6 +2,8 @@ require "isolation/abstract_unit" module PluginsTest class FrameworkExtensionTest < Test::Unit::TestCase + include ActiveSupport::Testing::Isolation + def setup build_app boot_rails @@ -23,12 +25,15 @@ module PluginsTest require 'rake' require 'rake/testtask' require 'rake/rdoctask' + AppTemplate::Application.load_tasks assert $ran_block end end class ActiveRecordExtensionTest < Test::Unit::TestCase + include ActiveSupport::Testing::Isolation + def setup build_app boot_rails |