diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 0b453b34aae511db33987a48a046ab2a4106f86b..bfa37aaf0f409c414148c3f2e710ee4ca8bd26a8 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -5,6 +5,8 @@
# Loads :classic_pagination before all the other plugins
config.plugins = [ :classic_pagination, :all ]
+* Added symbols as a legal way of specifying plugins in config.plugins #9629 [tom]
+
* Removed deprecated task names, like clear_logs, in favor of the new namespaced style [DHH]
* Support multiple config.after_initialize blocks so plugins and apps can more easily cooperate. #9582 [zdennis]
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 111b5237ba94ad1c1d6e6d4266ce8f3aacd8fdce..3183b0a34a1d9100a896386684101ce0c55322cd 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -429,7 +429,10 @@ class Configuration
# The list of plugins to load. If this is set to nil, all plugins will
# be loaded. If this is set to [], no plugins will be loaded. Otherwise,
# plugins will be loaded in the order specified.
- attr_accessor :plugins
+ attr_reader :plugins
+ def plugins=(plugins)
+ @plugins = plugins.nil? ? nil : plugins.map { |p| p.to_sym }
+ end
# The path to the root of the plugins directory. By default, it is in
# vendor/plugins.
diff --git a/railties/lib/rails/plugin/loader.rb b/railties/lib/rails/plugin/loader.rb
index e935f9b34b9ac1970c86903399948dbd57eecc60..016bcc6c506223ca90224013ee6842008b5aef3e 100644
--- a/railties/lib/rails/plugin/loader.rb
+++ b/railties/lib/rails/plugin/loader.rb
@@ -13,7 +13,7 @@ def load(*args)
def initialize(initializer, directory)
@initializer = initializer
@directory = directory
- @name = File.basename(directory)
+ @name = File.basename(directory).to_sym
end
def load
@@ -126,7 +126,7 @@ def <=>(other_plugin_loader)
end
if !explicitly_enabled? && !other_plugin_loader.explicitly_enabled?
- name <=> other_plugin_loader.name
+ name.to_s <=> other_plugin_loader.name.to_s
elsif registered_plugins.include?(:all) && (!explicitly_enabled? || !other_plugin_loader.explicitly_enabled?)
effective_index = explicitly_enabled? ? registered_plugins.index(name) : registered_plugins.index(:all)
other_effective_index = other_plugin_loader.explicitly_enabled? ?
@@ -138,7 +138,7 @@ def <=>(other_plugin_loader)
end
else
- name <=> other_plugin_loader.name
+ name.to_s <=> other_plugin_loader.name.to_s
end
end
end
diff --git a/railties/test/plugin_locator_test.rb b/railties/test/plugin_locator_test.rb
index cf6c0d9507abb113b620c3841e1683a9f70a8c08..3ac4493d47bc67ef472db5d7a3d7ebd6f87f2a3f 100644
--- a/railties/test/plugin_locator_test.rb
+++ b/railties/test/plugin_locator_test.rb
@@ -16,33 +16,39 @@ def test_no_plugins_are_loaded_if_the_configuration_has_an_empty_plugin_list
end
def test_only_the_specified_plugins_are_located_in_the_order_listed
- plugin_names = %w(stubby acts_as_chunky_bacon)
+ plugin_names = [:stubby, :acts_as_chunky_bacon]
only_load_the_following_plugins! plugin_names
assert_equal plugin_names, @locator.plugin_names
end
def test_all_plugins_are_loaded_when_registered_plugin_list_is_untouched
failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_equal %w(a acts_as_chunky_bacon plugin_with_no_lib_dir stubby), @locator.plugin_names, failure_tip
+ assert_equal [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @locator.plugin_names, failure_tip
end
def test_all_plugins_loaded_when_all_is_used
- plugin_names = ['stubby', 'acts_as_chunky_bacon', :all]
+ plugin_names = [:stubby, :acts_as_chunky_bacon, :all]
only_load_the_following_plugins! plugin_names
failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_equal %w(stubby acts_as_chunky_bacon a plugin_with_no_lib_dir), @locator.plugin_names, failure_tip
+ assert_equal [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @locator.plugin_names, failure_tip
end
def test_all_plugins_loaded_after_all
- plugin_names = ['stubby', :all, 'acts_as_chunky_bacon']
+ plugin_names = [:stubby, :all, :acts_as_chunky_bacon]
only_load_the_following_plugins! plugin_names
failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_equal %w(stubby a plugin_with_no_lib_dir acts_as_chunky_bacon ), @locator.plugin_names, failure_tip
+ assert_equal [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @locator.plugin_names, failure_tip
end
+ def test_plugin_names_may_be_strings
+ plugin_names = ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir]
+ only_load_the_following_plugins! plugin_names
+ failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
+ assert_equal [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @locator.plugin_names, failure_tip
+ end
def test_registering_a_plugin_name_that_does_not_exist_raises_a_load_error
- only_load_the_following_plugins! %w(stubby acts_as_a_non_existant_plugin)
+ only_load_the_following_plugins! [:stubby, :acts_as_a_non_existant_plugin]
assert_raises(LoadError) do
@initializer.load_plugins
end