aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/metal_test.rb
diff options
context:
space:
mode:
authorJeffrey Hardy <packagethief@gmail.com>2009-03-23 23:15:47 -0400
committerJeffrey Hardy <packagethief@gmail.com>2009-03-23 23:15:47 -0400
commit76556b08bb8d22dccd7c44e302f625442c5cc8f0 (patch)
tree560889c89fcaac57778b6cfe2ba135fd70a69f5c /railties/test/metal_test.rb
parent4b6458bf4cbf14007878b84a3fbc193f3365eebe (diff)
parentf7bdfe8bb76f7830cc2946cf0fcda2bb6d5e3e78 (diff)
downloadrails-76556b08bb8d22dccd7c44e302f625442c5cc8f0.tar.gz
rails-76556b08bb8d22dccd7c44e302f625442c5cc8f0.tar.bz2
rails-76556b08bb8d22dccd7c44e302f625442c5cc8f0.zip
Merge branch 'master' of git://github.com/lifo/docrails
* 'master' of git://github.com/lifo/docrails: (259 commits) Fix a small typo ensure authors get warnings about broken links, and ensure end users don't in guides generator, warn about duplicate header IDs only if WARN_DUPLICATE_HEADERS replace edit distance implementation with one written from scratch to avoid license issues removes a wrong comment in the finders guide updates fxn picture thanks but release notes are mostly frozen once they are published, and provide only an overview of the new stuff Added extra notes to nested model forms explanation in 2.3 release notes to cover has_one relationships clarifies a bit more what's the issue with check boxes and arrays of parameters be even more ambiguous about the order of generation of hidden input for check boxes in form helper guide this page referred to an :href_options keyword hash, in fact the correct keyword (the one the code responds to) is :html update explanation of check box generation according to f400209 Hidden field with check box goes first. update rack fixture to be ruby 1.9 compat Better error message to try to figure out why the CI build is failing ruby 1.9 compat: Pathname doesn't support =~ update rack fixture to be ruby 1.9 compat update metal fixtures to be ruby 1.9 compat Fix brittle Time.now mock Ensure our bundled version of rack is at the front of the load path ...
Diffstat (limited to 'railties/test/metal_test.rb')
-rw-r--r--railties/test/metal_test.rb72
1 files changed, 72 insertions, 0 deletions
diff --git a/railties/test/metal_test.rb b/railties/test/metal_test.rb
new file mode 100644
index 0000000000..d3d231132b
--- /dev/null
+++ b/railties/test/metal_test.rb
@@ -0,0 +1,72 @@
+require 'abstract_unit'
+require 'initializer'
+
+class MetalTest < Test::Unit::TestCase
+ def test_metals_should_return_list_of_found_metal_apps
+ use_appdir("singlemetal") do
+ assert_equal(["FooMetal"], found_metals_as_string_array)
+ end
+ end
+
+ def test_metals_should_respect_class_name_conventions
+ use_appdir("pluralmetal") do
+ assert_equal(["LegacyRoutes"], found_metals_as_string_array)
+ end
+ end
+
+ def test_metals_should_return_alphabetical_list_of_found_metal_apps
+ use_appdir("multiplemetals") do
+ assert_equal(["MetalA", "MetalB"], found_metals_as_string_array)
+ end
+ end
+
+ def test_metals_load_order_should_be_overriden_by_requested_metals
+ use_appdir("multiplemetals") do
+ Rails::Rack::Metal.requested_metals = ["MetalB", "MetalA"]
+ assert_equal(["MetalB", "MetalA"], found_metals_as_string_array)
+ end
+ end
+
+ def test_metals_not_listed_should_not_load
+ use_appdir("multiplemetals") do
+ Rails::Rack::Metal.requested_metals = ["MetalB"]
+ assert_equal(["MetalB"], found_metals_as_string_array)
+ end
+ end
+
+ def test_metal_finding_should_work_with_subfolders
+ use_appdir("subfolders") do
+ assert_equal(["Folder::MetalA", "Folder::MetalB"], found_metals_as_string_array)
+ end
+ end
+
+ def test_metal_finding_with_requested_metals_should_work_with_subfolders
+ use_appdir("subfolders") do
+ Rails::Rack::Metal.requested_metals = ["Folder::MetalB"]
+ assert_equal(["Folder::MetalB"], found_metals_as_string_array)
+ end
+ end
+
+ def test_metal_finding_should_work_with_multiple_metal_paths_in_185_and_below
+ use_appdir("singlemetal") do
+ engine_metal_path = "#{File.dirname(__FILE__)}/fixtures/plugins/engines/engine/app/metal"
+ Rails::Rack::Metal.metal_paths << engine_metal_path
+ $LOAD_PATH << engine_metal_path
+ assert_equal(["FooMetal", "EngineMetal"], found_metals_as_string_array)
+ end
+ end
+
+ private
+
+ def use_appdir(root)
+ dir = "#{File.dirname(__FILE__)}/fixtures/metal/#{root}"
+ Rails::Rack::Metal.metal_paths = ["#{dir}/app/metal"]
+ Rails::Rack::Metal.requested_metals = nil
+ $LOAD_PATH << "#{dir}/app/metal"
+ yield
+ end
+
+ def found_metals_as_string_array
+ Rails::Rack::Metal.metals.map { |m| m.to_s }
+ end
+end