diff options
author | José Valim and Mikel Lindsaar <raasdnil@gmail.com> | 2010-01-22 13:37:29 +1100 |
---|---|---|
committer | José Valim and Mikel Lindsaar <raasdnil@gmail.com> | 2010-01-22 13:37:29 +1100 |
commit | 8a6a2ca712601a28087f78fb6080b05f526cb0fd (patch) | |
tree | de9347d6a398a4317e0c87981e8c75d442e141d7 /railties/test | |
parent | c9dc1ac95bc97800dd3deb82fe1cf6f98e27413d (diff) | |
parent | 6d30002a52133bd105adb29084f4cc72b1ee847f (diff) | |
download | rails-8a6a2ca712601a28087f78fb6080b05f526cb0fd.tar.gz rails-8a6a2ca712601a28087f78fb6080b05f526cb0fd.tar.bz2 rails-8a6a2ca712601a28087f78fb6080b05f526cb0fd.zip |
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/configuration_test.rb | 12 | ||||
-rw-r--r-- | railties/test/application/middleware_test.rb | 2 | ||||
-rw-r--r-- | railties/test/fixtures/lib/generators/model_generator.rb | 1 | ||||
-rw-r--r-- | railties/test/fixtures/lib/rails_generators/foobar/foobar_generator.rb (renamed from railties/test/fixtures/lib/generators/foobar/foobar_generator.rb) | 0 | ||||
-rw-r--r-- | railties/test/generators_test.rb | 8 | ||||
-rw-r--r-- | railties/test/subscriber_test.rb | 45 |
6 files changed, 32 insertions, 36 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 79dfacdcdb..6968e87986 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -122,5 +122,17 @@ module ApplicationTests require "#{app_path}/config/environment" end end + + test "filter_parameters should be able to set via config.filter_parameters" do + add_to_config <<-RUBY + config.filter_parameters += [ :foo, 'bar', lambda { |key, value| + value = value.reverse if key =~ /baz/ + }] + RUBY + + assert_nothing_raised do + require "#{app_path}/config/application" + end + end end end diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index 1c5cc62ecd..8c4247e840 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -17,8 +17,8 @@ module ApplicationTests "ActionDispatch::Static", "Rack::Lock", "Rack::Runtime", + "Rails::Rack::Logger", "ActionDispatch::ShowExceptions", - "ActionDispatch::Notifications", "ActionDispatch::Callbacks", "ActionDispatch::Cookies", "ActionDispatch::Session::CookieStore", diff --git a/railties/test/fixtures/lib/generators/model_generator.rb b/railties/test/fixtures/lib/generators/model_generator.rb new file mode 100644 index 0000000000..9098a8a354 --- /dev/null +++ b/railties/test/fixtures/lib/generators/model_generator.rb @@ -0,0 +1 @@ +raise "I should never be loaded"
\ No newline at end of file diff --git a/railties/test/fixtures/lib/generators/foobar/foobar_generator.rb b/railties/test/fixtures/lib/rails_generators/foobar/foobar_generator.rb index d1de8c56fa..d1de8c56fa 100644 --- a/railties/test/fixtures/lib/generators/foobar/foobar_generator.rb +++ b/railties/test/fixtures/lib/rails_generators/foobar/foobar_generator.rb diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index 664d1e5670..f37b684f73 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -16,6 +16,7 @@ class GeneratorsTest < Rails::Generators::TestCase end def test_simple_invoke + assert File.exists?(File.join(@path, 'generators', 'model_generator.rb')) TestUnit::Generators::ModelGenerator.expects(:start).with(["Account"], {}) Rails::Generators.invoke("test_unit:model", ["Account"]) end @@ -30,6 +31,13 @@ class GeneratorsTest < Rails::Generators::TestCase assert_match /Description:/, output end + def test_should_give_higher_preference_to_rails_generators + assert File.exists?(File.join(@path, 'generators', 'model_generator.rb')) + Rails::Generators::ModelGenerator.expects(:start).with(["Account"], {}) + warnings = capture(:stderr){ Rails::Generators.invoke :model, ["Account"] } + assert warnings.empty? + end + def test_invoke_with_default_values Rails::Generators::ModelGenerator.expects(:start).with(["Account"], {}) Rails::Generators.invoke :model, ["Account"] diff --git a/railties/test/subscriber_test.rb b/railties/test/subscriber_test.rb index 724e8a75d6..f6c895093f 100644 --- a/railties/test/subscriber_test.rb +++ b/railties/test/subscriber_test.rb @@ -24,7 +24,9 @@ class MySubscriber < Rails::Subscriber end end -module SubscriberTest +class SyncSubscriberTest < ActiveSupport::TestCase + include Rails::Subscriber::TestHelper + def setup super @subscriber = MySubscriber.new @@ -94,51 +96,24 @@ module SubscriberTest assert_equal 1, @logger.flush_count end - def test_flushes_loggers_when_action_dispatch_callback_is_received - Rails::Subscriber.add :my_subscriber, @subscriber - instrument "action_dispatch.after_dispatch" - wait - assert_equal 1, @logger.flush_count - end - def test_flushes_the_same_logger_just_once Rails::Subscriber.add :my_subscriber, @subscriber Rails::Subscriber.add :another, @subscriber - instrument "action_dispatch.after_dispatch" + Rails::Subscriber.flush_all! wait assert_equal 1, @logger.flush_count end - def test_logging_thread_does_not_die_on_failures + def test_logging_does_not_die_on_failures Rails::Subscriber.add :my_subscriber, @subscriber instrument "my_subscriber.puke" - instrument "action_dispatch.after_dispatch" - wait - assert_equal 1, @logger.flush_count - assert_equal 1, @logger.logged(:error).size - assert_equal 'Could not log "my_subscriber.puke" event. RuntimeError: puke', @logger.logged(:error).last - end - - def test_tails_logs_when_action_dispatch_callback_is_received - log_tailer = mock() - log_tailer.expects(:tail!) - Rails::Subscriber.log_tailer = log_tailer - - Rails::Subscriber.add :my_subscriber, @subscriber - instrument "action_dispatch.after_dispatch" + instrument "my_subscriber.some_event" wait - ensure - Rails::Subscriber.log_tailer = nil - end - class SyncSubscriberTest < ActiveSupport::TestCase - include Rails::Subscriber::SyncTestHelper - include SubscriberTest - end + assert_equal 1, @logger.logged(:info).size + assert_equal 'my_subscriber.some_event', @logger.logged(:info).last - class AsyncSubscriberTest < ActiveSupport::TestCase - include Rails::Subscriber::AsyncTestHelper - include SubscriberTest + assert_equal 1, @logger.logged(:error).size + assert_equal 'Could not log "my_subscriber.puke" event. RuntimeError: puke', @logger.logged(:error).last end - end
\ No newline at end of file |