aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/configuration_test.rb21
-rw-r--r--railties/test/application/initializer_test.rb1
-rw-r--r--railties/test/application/routing_test.rb70
-rw-r--r--railties/test/plugins/configuration_test.rb36
4 files changed, 128 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/application/routing_test.rb b/railties/test/application/routing_test.rb
index 1bfec3805b..decde056fd 100644
--- a/railties/test/application/routing_test.rb
+++ b/railties/test/application/routing_test.rb
@@ -81,5 +81,75 @@ module ApplicationTests
get '/admin/foo'
assert_equal 'admin::foo', last_response.body
end
+
+ test "merges with plugin routes" do
+ controller 'foo', <<-RUBY
+ class FooController < ActionController::Base
+ def index
+ render :text => "foo"
+ end
+ end
+ RUBY
+
+ app_file 'config/routes.rb', <<-RUBY
+ ActionController::Routing::Routes.draw do |map|
+ match 'foo', :to => 'foo#index'
+ end
+ RUBY
+
+ plugin 'bar', 'require File.dirname(__FILE__) + "/app/controllers/bar"' do |plugin|
+ plugin.write 'app/controllers/bar.rb', <<-RUBY
+ class BarController < ActionController::Base
+ def index
+ render :text => "bar"
+ end
+ end
+ RUBY
+
+ plugin.write 'config/routes.rb', <<-RUBY
+ ActionController::Routing::Routes.draw do |map|
+ match 'bar', :to => 'bar#index'
+ end
+ RUBY
+ end
+
+ get '/foo'
+ assert_equal 'foo', last_response.body
+
+ get '/bar'
+ assert_equal 'bar', last_response.body
+ end
+
+ test "reloads routes when configuration is changed" do
+ controller :foo, <<-RUBY
+ class FooController < ActionController::Base
+ def bar
+ render :text => "bar"
+ end
+
+ def baz
+ render :text => "baz"
+ end
+ end
+ RUBY
+
+ app_file 'config/routes.rb', <<-RUBY
+ ActionController::Routing::Routes.draw do |map|
+ match 'foo', :to => 'foo#bar'
+ end
+ RUBY
+
+ get '/foo'
+ assert_equal 'bar', last_response.body
+
+ app_file 'config/routes.rb', <<-RUBY
+ ActionController::Routing::Routes.draw do |map|
+ match 'foo', :to => 'foo#baz'
+ end
+ RUBY
+
+ get '/foo'
+ assert_equal 'baz', last_response.body
+ end
end
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