diff options
author | Carl Lerche <carllerche@mac.com> | 2009-12-15 22:07:12 -0800 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2009-12-15 22:13:52 -0800 |
commit | 1b27f5c4f72384081083fa025b6b10e5ab02ae5e (patch) | |
tree | 43bbf10ed39c70f7937709de8b0805002f93eca5 /railties/test | |
parent | f0bbc647c2086e9536c9d2b4ea7c4c18fe2edd3e (diff) | |
download | rails-1b27f5c4f72384081083fa025b6b10e5ab02ae5e.tar.gz rails-1b27f5c4f72384081083fa025b6b10e5ab02ae5e.tar.bz2 rails-1b27f5c4f72384081083fa025b6b10e5ab02ae5e.zip |
Add the ability for plugins to set default configuration settings.
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/configuration_test.rb | 21 | ||||
-rw-r--r-- | railties/test/application/initializer_test.rb | 1 | ||||
-rw-r--r-- | railties/test/plugins/configuration_test.rb | 36 |
3 files changed, 58 insertions, 0 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 1fcab8c651..89337b7f66 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -53,5 +53,26 @@ module ApplicationTests assert_raises(NoMethodError) { 1.day } end end + + test "marking the application as threadsafe sets the correct config variables" do + add_to_config <<-RUBY + config.threadsafe! + RUBY + + require "#{app_path}/config/application" + assert AppTemplate.configuration.action_controller.allow_concurrency + end + + test "the application can be marked as threadsafe when there are no frameworks" do + FileUtils.rm_rf("#{app_path}/config/environments") + add_to_config <<-RUBY + config.frameworks = [] + config.threadsafe! + RUBY + + assert_nothing_raised do + require "#{app_path}/config/application" + end + end end end diff --git a/railties/test/application/initializer_test.rb b/railties/test/application/initializer_test.rb index 56582c5772..fa00d287ca 100644 --- a/railties/test/application/initializer_test.rb +++ b/railties/test/application/initializer_test.rb @@ -6,6 +6,7 @@ module ApplicationTests def setup build_app + FileUtils.rm_rf("#{app_path}/config/environments") boot_rails require "rails" end diff --git a/railties/test/plugins/configuration_test.rb b/railties/test/plugins/configuration_test.rb new file mode 100644 index 0000000000..edf8bb37f5 --- /dev/null +++ b/railties/test/plugins/configuration_test.rb @@ -0,0 +1,36 @@ +require "isolation/abstract_unit" + +module PluginsTest + class ConfigurationTest < Test::Unit::TestCase + def setup + build_app + boot_rails + require "rails" + end + + test "config is available to plugins" do + class Foo < Rails::Plugin ; end + assert_nil Foo.config.action_controller.foo + end + + test "a config name is available for the plugin" do + class Foo < Rails::Plugin ; config.foo.greetings = "hello" ; end + assert_equal "hello", Foo.config.foo.greetings + end + + test "plugin configurations are available in the application" do + class Foo < Rails::Plugin ; config.foo.greetings = "hello" ; end + require "#{app_path}/config/application" + assert_equal "hello", AppTemplate.config.foo.greetings + end + + test "plugin config merges are deep" do + class Foo < Rails::Plugin ; config.foo.greetings = 'hello' ; end + class MyApp < Rails::Application + config.foo.bar = "bar" + end + assert_equal "hello", MyApp.config.foo.greetings + assert_equal "bar", MyApp.config.foo.bar + end + end +end
\ No newline at end of file |