diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-28 19:46:17 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-28 19:46:17 +0000 |
commit | 285361d1589002fcdd1584c07e6eb295f13c9f37 (patch) | |
tree | 2d50a69b3b59b6fb3cb7577b990fe3b1aaf58f4f /railties/test/plugins | |
parent | dfa19408651ecc82e2aeba95d93db871ba8a6e41 (diff) | |
parent | d58398c2b5e98aad18dc72790230f338c10d145c (diff) | |
download | rails-285361d1589002fcdd1584c07e6eb295f13c9f37.tar.gz rails-285361d1589002fcdd1584c07e6eb295f13c9f37.tar.bz2 rails-285361d1589002fcdd1584c07e6eb295f13c9f37.zip |
Merge remote branch 'mainstream/master'
Conflicts:
railties/lib/rails/railtie.rb
Diffstat (limited to 'railties/test/plugins')
-rw-r--r-- | railties/test/plugins/configuration_test.rb | 45 | ||||
-rw-r--r-- | railties/test/plugins/framework_extension_test.rb | 68 | ||||
-rw-r--r-- | railties/test/plugins/vendored_test.rb | 201 |
3 files changed, 0 insertions, 314 deletions
diff --git a/railties/test/plugins/configuration_test.rb b/railties/test/plugins/configuration_test.rb deleted file mode 100644 index 09f8943af9..0000000000 --- a/railties/test/plugins/configuration_test.rb +++ /dev/null @@ -1,45 +0,0 @@ -require "isolation/abstract_unit" - -module PluginsTest - class ConfigurationTest < Test::Unit::TestCase - def setup - build_app - boot_rails - require "rails/all" - end - - test "config is available to plugins" do - class Foo < Rails::Railtie ; end - assert_nil Foo.config.action_controller.foo - end - - test "a config name is available for the plugin" do - class Foo < Rails::Railtie ; 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::Railtie ; config.foo.greetings = "hello" ; end - require "#{app_path}/config/application" - assert_equal "hello", AppTemplate::Application.config.foo.greetings - end - - test "plugin config merges are deep" do - class Foo < Rails::Railtie ; 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 - - test "plugin can add subscribers" do - begin - class Foo < Rails::Railtie; subscriber(Rails::Subscriber.new); end - assert_kind_of Rails::Subscriber, Rails::Subscriber.subscribers[:foo] - ensure - Rails::Subscriber.subscribers.clear - end - end - end -end diff --git a/railties/test/plugins/framework_extension_test.rb b/railties/test/plugins/framework_extension_test.rb deleted file mode 100644 index d57fd4e635..0000000000 --- a/railties/test/plugins/framework_extension_test.rb +++ /dev/null @@ -1,68 +0,0 @@ -require "isolation/abstract_unit" - -module PluginsTest - class FrameworkExtensionTest < Test::Unit::TestCase - include ActiveSupport::Testing::Isolation - - def setup - build_app - boot_rails - FileUtils.rm_rf("#{app_path}/config/environments") - require "rails/all" - end - - test "rake_tasks block is executed when MyApp.load_tasks is called" do - $ran_block = false - - class MyTie < Rails::Railtie - rake_tasks do - $ran_block = true - end - end - - require "#{app_path}/config/environment" - - assert !$ran_block - require 'rake' - require 'rake/testtask' - require 'rake/rdoctask' - - AppTemplate::Application.load_tasks - assert $ran_block - end - - test "generators block is executed when MyApp.load_generators is called" do - $ran_block = false - - class MyTie < Rails::Railtie - generators do - $ran_block = true - end - end - - require "#{app_path}/config/environment" - - assert !$ran_block - AppTemplate::Application.load_generators - assert $ran_block - end - end - - class ActiveRecordExtensionTest < Test::Unit::TestCase - include ActiveSupport::Testing::Isolation - - def setup - build_app - boot_rails - FileUtils.rm_rf("#{app_path}/config/environments") - end - - test "active_record extensions are applied to ActiveRecord" do - add_to_config "config.active_record.table_name_prefix = 'tbl_'" - - require "#{app_path}/config/environment" - - assert_equal 'tbl_', ActiveRecord::Base.table_name_prefix - end - end -end
\ No newline at end of file diff --git a/railties/test/plugins/vendored_test.rb b/railties/test/plugins/vendored_test.rb deleted file mode 100644 index b3b85891b2..0000000000 --- a/railties/test/plugins/vendored_test.rb +++ /dev/null @@ -1,201 +0,0 @@ -require "isolation/abstract_unit" - -module PluginsTest - class VendoredTest < Test::Unit::TestCase - include ActiveSupport::Testing::Isolation - - def setup - build_app - - @plugin = plugin "bukkits", "::LEVEL = config.log_level" do |plugin| - plugin.write "lib/bukkits.rb", "class Bukkits; end" - end - end - - def boot_rails - super - require "#{app_path}/config/environment" - end - - test "it loads the plugin's init.rb file" do - boot_rails - assert_equal "loaded", BUKKITS - end - - test "the init.rb file has access to the config object" do - boot_rails - assert_equal :debug, LEVEL - end - - test "the plugin puts its lib directory on the load path" do - boot_rails - require "bukkits" - assert_equal "Bukkits", Bukkits.name - end - - test "plugin paths get added to the AS::Dependency list" do - boot_rails - assert_equal "Bukkits", Bukkits.name - end - - test "plugin constants do not get reloaded by default" do - boot_rails - assert_equal "Bukkits", Bukkits.name - ActiveSupport::Dependencies.clear - @plugin.delete("lib/bukkits.rb") - assert_nothing_raised { Bukkits } - end - - test "plugin constants get reloaded if config.reload_plugins is set" do - add_to_config <<-RUBY - config.reload_plugins = true - RUBY - - boot_rails - - assert_equal "Bukkits", Bukkits.name - ActiveSupport::Dependencies.clear - @plugin.delete("lib/bukkits.rb") - assert_raises(NameError) { Bukkits } - end - - test "plugin should work without init.rb" do - @plugin.delete("init.rb") - - boot_rails - - require "bukkits" - assert_nothing_raised { Bukkits } - end - - test "the plugin puts its models directory on the load path" do - @plugin.write "app/models/my_bukkit.rb", "class MyBukkit ; end" - - boot_rails - - assert_nothing_raised { MyBukkit } - end - - test "the plugin puts is controllers directory on the load path" do - @plugin.write "app/controllers/bukkit_controller.rb", "class BukkitController ; end" - - boot_rails - - assert_nothing_raised { BukkitController } - end - - test "the plugin adds its view to the load path" do - @plugin.write "app/controllers/bukkit_controller.rb", <<-RUBY - class BukkitController < ActionController::Base - def index - end - end - RUBY - - @plugin.write "app/views/bukkit/index.html.erb", "Hello bukkits" - - boot_rails - - require "action_controller" - require "rack/mock" - response = BukkitController.action(:index).call(Rack::MockRequest.env_for("/")) - assert_equal "Hello bukkits\n", response[2].body - end - - test "the plugin adds helpers to the controller's views" do - @plugin.write "app/controllers/bukkit_controller.rb", <<-RUBY - class BukkitController < ActionController::Base - def index - end - end - RUBY - - @plugin.write "app/helpers/bukkit_helper.rb", <<-RUBY - module BukkitHelper - def bukkits - "bukkits" - end - end - RUBY - - @plugin.write "app/views/bukkit/index.html.erb", "Hello <%= bukkits %>" - - boot_rails - - require "rack/mock" - response = BukkitController.action(:index).call(Rack::MockRequest.env_for("/")) - assert_equal "Hello bukkits\n", response[2].body - end - - test "routes.rb are added to the router" do - @plugin.write "config/routes.rb", <<-RUBY - class Sprokkit - def self.call(env) - [200, {'Content-Type' => 'text/html'}, ["I am a Sprokkit"]] - end - end - - ActionController::Routing::Routes.draw do - match "/sprokkit", :to => Sprokkit - end - RUBY - - boot_rails - require "rack/mock" - response = Rails.application.call(Rack::MockRequest.env_for("/sprokkit")) - assert_equal "I am a Sprokkit", response[2].join - end - end - - class VendoredOrderingTest < Test::Unit::TestCase - include ActiveSupport::Testing::Isolation - - def setup - build_app - $arr = [] - plugin "a_plugin", "$arr << :a" - plugin "b_plugin", "$arr << :b" - plugin "c_plugin", "$arr << :c" - end - - def boot_rails - super - require "#{app_path}/config/environment" - end - - test "plugins are loaded alphabetically by default" do - boot_rails - assert_equal [:a, :b, :c], $arr - end - - test "if specified, only those plugins are loaded" do - add_to_config "config.plugins = [:b_plugin]" - boot_rails - assert_equal [:b], $arr - end - - test "the plugins are initialized in the order they are specified" do - add_to_config "config.plugins = [:b_plugin, :a_plugin]" - boot_rails - assert_equal [:b, :a], $arr - end - - test "if :all is specified, the remaining plugins are loaded in alphabetical order" do - add_to_config "config.plugins = [:c_plugin, :all]" - boot_rails - assert_equal [:c, :a, :b], $arr - end - - test "if :all is at the beginning, it represents the plugins not otherwise specified" do - add_to_config "config.plugins = [:all, :b_plugin]" - boot_rails - assert_equal [:a, :c, :b], $arr - end - - test "plugin order array is strings" do - add_to_config "config.plugins = %w( c_plugin all )" - boot_rails - assert_equal [:c, :a, :b], $arr - end - end -end |