aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/railties
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-01-02 18:49:18 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2012-01-03 10:39:08 -0200
commitdad7fdc5734a3813246f238ac5760b2076932216 (patch)
tree84904473ab7af22f4ee29d86c75106050a25082e /railties/test/railties
parentb627923b3c11bd5a0d05a1c601a92141703354c1 (diff)
downloadrails-dad7fdc5734a3813246f238ac5760b2076932216.tar.gz
rails-dad7fdc5734a3813246f238ac5760b2076932216.tar.bz2
rails-dad7fdc5734a3813246f238ac5760b2076932216.zip
Rails::Plugin has gone
Diffstat (limited to 'railties/test/railties')
-rw-r--r--railties/test/railties/engine_test.rb40
-rw-r--r--railties/test/railties/plugin_ordering_test.rb76
-rw-r--r--railties/test/railties/plugin_test.rb123
-rw-r--r--railties/test/railties/shared_tests.rb13
4 files changed, 0 insertions, 252 deletions
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`