diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-01-02 18:49:18 -0200 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2012-01-03 10:39:08 -0200 |
commit | dad7fdc5734a3813246f238ac5760b2076932216 (patch) | |
tree | 84904473ab7af22f4ee29d86c75106050a25082e /railties/test | |
parent | b627923b3c11bd5a0d05a1c601a92141703354c1 (diff) | |
download | rails-dad7fdc5734a3813246f238ac5760b2076932216.tar.gz rails-dad7fdc5734a3813246f238ac5760b2076932216.tar.bz2 rails-dad7fdc5734a3813246f238ac5760b2076932216.zip |
Rails::Plugin has gone
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/paths_test.rb | 1 | ||||
-rw-r--r-- | railties/test/generators/actions_test.rb | 37 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 1 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 14 | ||||
-rw-r--r-- | railties/test/railties/engine_test.rb | 40 | ||||
-rw-r--r-- | railties/test/railties/plugin_ordering_test.rb | 76 | ||||
-rw-r--r-- | railties/test/railties/plugin_test.rb | 123 | ||||
-rw-r--r-- | railties/test/railties/shared_tests.rb | 13 |
8 files changed, 0 insertions, 305 deletions
diff --git a/railties/test/application/paths_test.rb b/railties/test/application/paths_test.rb index 964cff48cd..84f4408147 100644 --- a/railties/test/application/paths_test.rb +++ b/railties/test/application/paths_test.rb @@ -46,7 +46,6 @@ module ApplicationTests assert_path @paths["app/views"], "app/views" assert_path @paths["lib"], "lib" assert_path @paths["vendor"], "vendor" - assert_path @paths["vendor/plugins"], "vendor/plugins" assert_path @paths["tmp"], "tmp" assert_path @paths["config"], "config" assert_path @paths["config/locales"], "config/locales/en.yml" diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index ee288871de..a8c8fcd5b7 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -9,8 +9,6 @@ class ActionsTest < Rails::Generators::TestCase def setup Rails.application = TestApp::Application super - @git_plugin_uri = 'git://github.com/technoweenie/restful-authentication.git' - @svn_plugin_uri = 'svn://svnhub.com/technoweenie/restful-authentication/trunk' end def teardown @@ -37,41 +35,6 @@ class ActionsTest < Rails::Generators::TestCase assert_file 'lib/test_file.rb', 'heres block data' end - def test_plugin_with_git_option_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/rails plugin install #{@git_plugin_uri}", :verbose => false) - action :plugin, 'restful-authentication', :git => @git_plugin_uri - end - - def test_plugin_with_svn_option_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/rails plugin install #{@svn_plugin_uri}", :verbose => false) - action :plugin, 'restful-authentication', :svn => @svn_plugin_uri - end - - def test_plugin_with_git_option_and_branch_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/rails plugin install -b stable #{@git_plugin_uri}", :verbose => false) - action :plugin, 'restful-authentication', :git => @git_plugin_uri, :branch => 'stable' - end - - def test_plugin_with_svn_option_and_revision_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/rails plugin install -r 1234 #{@svn_plugin_uri}", :verbose => false) - action :plugin, 'restful-authentication', :svn => @svn_plugin_uri, :revision => 1234 - end - - def test_plugin_with_git_option_and_submodule_should_use_git_scm - generator.expects(:run).with("git submodule add #{@git_plugin_uri} vendor/plugins/rest_auth", :verbose => false) - action :plugin, 'rest_auth', :git => @git_plugin_uri, :submodule => true - end - - def test_plugin_with_git_option_and_submodule_should_use_git_scm - generator.expects(:run).with("git submodule add -b stable #{@git_plugin_uri} vendor/plugins/rest_auth", :verbose => false) - action :plugin, 'rest_auth', :git => @git_plugin_uri, :submodule => true, :branch => 'stable' - end - - def test_plugin_with_no_options_should_skip_method - generator.expects(:run).never - action :plugin, 'rest_auth', {} - end - def test_add_source_adds_source_to_gemfile run_generator action :add_source, 'http://gems.github.com' diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index a15943dfc6..70ef37ee0f 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -32,7 +32,6 @@ DEFAULT_APP_FILES = %w( test/unit vendor vendor/assets - vendor/plugins tmp/cache tmp/cache/assets ) diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 06b658e7bd..f57737172d 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -178,20 +178,6 @@ module TestHelpers end end - def plugin(name, string = "") - dir = "#{app_path}/vendor/plugins/#{name}" - FileUtils.mkdir_p(dir) - - File.open("#{dir}/init.rb", 'w') do |f| - f.puts "::#{name.upcase} = 'loaded'" - f.puts string - end - - Bukkit.new(dir).tap do |bukkit| - yield bukkit if block_given? - end - end - def engine(name) dir = "#{app_path}/random/#{name}" FileUtils.mkdir_p(dir) diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 400cae98b2..2813f689c5 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -151,46 +151,6 @@ module RailtiesTest assert_equal "foo", last_response.body end - test "engine can load its own plugins" do - @plugin.write "lib/bukkits.rb", <<-RUBY - module Bukkits - class Engine < ::Rails::Engine - end - end - RUBY - - @plugin.write "vendor/plugins/yaffle/init.rb", <<-RUBY - config.yaffle_loaded = true - RUBY - - boot_rails - - assert Bukkits::Engine.config.yaffle_loaded - end - - test "engine does not load plugins that already exists in application" do - @plugin.write "lib/bukkits.rb", <<-RUBY - module Bukkits - class Engine < ::Rails::Engine - end - end - RUBY - - @plugin.write "vendor/plugins/yaffle/init.rb", <<-RUBY - config.engine_yaffle_loaded = true - RUBY - - app_file "vendor/plugins/yaffle/init.rb", <<-RUBY - config.app_yaffle_loaded = true - RUBY - - warnings = capture(:stderr) { boot_rails } - - assert !warnings.empty? - assert !Bukkits::Engine.config.respond_to?(:engine_yaffle_loaded) - assert Rails.application.config.app_yaffle_loaded - end - test "it loads its environment file" do @plugin.write "lib/bukkits.rb", <<-RUBY module Bukkits diff --git a/railties/test/railties/plugin_ordering_test.rb b/railties/test/railties/plugin_ordering_test.rb deleted file mode 100644 index 1cfaf557e9..0000000000 --- a/railties/test/railties/plugin_ordering_test.rb +++ /dev/null @@ -1,76 +0,0 @@ -require "isolation/abstract_unit" - -module RailtiesTest - class PluginOrderingTest < 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 teardown - teardown_app - 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 - - test "can require lib file from a different plugin" do - plugin "foo", "require 'bar'" do |plugin| - plugin.write "lib/foo.rb", "$foo = true" - end - - plugin "bar", "require 'foo'" do |plugin| - plugin.write "lib/bar.rb", "$bar = true" - end - - add_to_config "config.plugins = [:foo, :bar]" - - boot_rails - - assert $foo - assert $bar - end - end -end diff --git a/railties/test/railties/plugin_test.rb b/railties/test/railties/plugin_test.rb deleted file mode 100644 index f307d53cf7..0000000000 --- a/railties/test/railties/plugin_test.rb +++ /dev/null @@ -1,123 +0,0 @@ -require "isolation/abstract_unit" -require "railties/shared_tests" - -module RailtiesTest - class PluginTest < Test::Unit::TestCase - include ActiveSupport::Testing::Isolation - include SharedTests - - def setup - build_app - - @plugin = plugin "bukkits", "::LEVEL = config.log_level" do |plugin| - plugin.write "lib/bukkits.rb", "class Bukkits; end" - plugin.write "lib/another.rb", "class Another; end" - end - end - - def teardown - teardown_app - end - - test "Rails::Plugin itself does not respond to config" do - boot_rails - assert !Rails::Plugin.respond_to?(:config) - end - - test "cannot inherit from Rails::Plugin" do - boot_rails - assert_raise RuntimeError do - class Foo < Rails::Plugin; end - end - end - - test "plugin can load the file with the same name in lib" do - boot_rails - require "bukkits" - assert_equal "Bukkits", Bukkits.name - end - - test "plugin gets added to dependency list" do - boot_rails - assert_equal "Another", Another.name - end - - test "plugin constants get reloaded if config.reload_plugins is set to true" do - add_to_config <<-RUBY - config.reload_plugins = true - RUBY - - boot_rails - - assert_equal "Another", Another.name - ActiveSupport::Dependencies.clear - @plugin.delete("lib/another.rb") - assert_raises(NameError) { Another } - end - - test "plugin constants are not reloaded by default" do - boot_rails - assert_equal "Another", Another.name - ActiveSupport::Dependencies.clear - @plugin.delete("lib/another.rb") - assert_nothing_raised { Another } - 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 "plugin_init_is_run_before_application_ones" do - plugin "foo", "$foo = true" do |plugin| - plugin.write "lib/foo.rb", "module Foo; end" - end - - app_file 'config/initializers/foo.rb', <<-RUBY - raise "no $foo" unless $foo - raise "no Foo" unless Foo - RUBY - - boot_rails - assert $foo - end - - test "plugin should work without init.rb" do - @plugin.delete("init.rb") - - boot_rails - - require "bukkits" - assert_nothing_raised { Bukkits } - end - - test "plugin cannot declare an engine for it" do - @plugin.write "lib/bukkits.rb", <<-RUBY - class Bukkits - class Engine < Rails::Engine - end - end - RUBY - - @plugin.write "init.rb", <<-RUBY - require "bukkits" - RUBY - - rescued = false - - begin - boot_rails - rescue Exception => e - rescued = true - assert_equal '"bukkits" is a Railtie/Engine and cannot be installed as a plugin', e.message - end - - assert rescued, "Expected boot rails to fail" - end - end -end diff --git a/railties/test/railties/shared_tests.rb b/railties/test/railties/shared_tests.rb index a15dae2a0a..3630a0937c 100644 --- a/railties/test/railties/shared_tests.rb +++ b/railties/test/railties/shared_tests.rb @@ -61,15 +61,6 @@ module RailtiesTest end RUBY - yaffle = plugin "acts_as_yaffle", "::LEVEL = config.log_level" do |plugin| - plugin.write "lib/acts_as_yaffle.rb", "class ActsAsYaffle; end" - end - - yaffle.write "db/migrate/1_create_yaffles.rb", <<-RUBY - class CreateYaffles < ActiveRecord::Migration - end - RUBY - add_to_config "ActiveRecord::Base.timestamped_migrations = false" boot_rails @@ -87,14 +78,10 @@ module RailtiesTest output = `bundle exec rake railties:install:migrations`.split("\n") - assert File.exists?("#{app_path}/db/migrate/4_create_yaffles.acts_as_yaffle.rb") assert_no_match(/2_create_users/, output.join("\n")) - yaffle_migration_order = output.index(output.detect{|o| /Copied migration 4_create_yaffles.acts_as_yaffle.rb from acts_as_yaffle/ =~ o }) bukkits_migration_order = output.index(output.detect{|o| /NOTE: Migration 3_create_sessions.rb from bukkits has been skipped/ =~ o }) - assert_not_nil yaffle_migration_order, "Expected migration to be copied" assert_not_nil bukkits_migration_order, "Expected migration to be skipped" - assert_equal(railties.index('acts_as_yaffle') > railties.index('bukkits'), yaffle_migration_order > bukkits_migration_order) migrations_count = Dir["#{app_path}/db/migrate/*.rb"].length output = `bundle exec rake railties:install:migrations` |