aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorStefan Sprenger <stefan.sprenger@dkd.de>2011-06-07 11:21:38 +0200
committerStefan Sprenger <stefan.sprenger@dkd.de>2011-06-07 11:21:38 +0200
commitf18283194bfb43fc020be37d6fa7cd3149fa8b5e (patch)
tree3b9501f6ee44039575f4858b24749967fc7dc898 /railties/test
parent1a06530aa50e1aed5c7dff6f1256abb555c497b6 (diff)
downloadrails-f18283194bfb43fc020be37d6fa7cd3149fa8b5e.tar.gz
rails-f18283194bfb43fc020be37d6fa7cd3149fa8b5e.tar.bz2
rails-f18283194bfb43fc020be37d6fa7cd3149fa8b5e.zip
Use namespace if it's a mountable engine
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/railties/generators_test.rb53
1 files changed, 44 insertions, 9 deletions
diff --git a/railties/test/railties/generators_test.rb b/railties/test/railties/generators_test.rb
index 69ba03673e..4f96e4d9ef 100644
--- a/railties/test/railties/generators_test.rb
+++ b/railties/test/railties/generators_test.rb
@@ -30,11 +30,13 @@ module RailtiesTests
`#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/bin/rails #{cmd}`
end
- def build_engine
+ def build_engine(is_mountable=false)
FileUtils.mkdir_p(engine_path)
FileUtils.rm_r(engine_path)
- rails("plugin new #{engine_path} --full --mountable")
+ mountable = is_mountable ? "--mountable" : ""
+
+ rails("plugin new #{engine_path} --full #{mountable}")
Dir.chdir(engine_path) do
File.open("Gemfile", "w") do |f|
@@ -52,32 +54,65 @@ module RailtiesTests
end
end
+ def build_mountable_engine
+ build_engine(true)
+ end
+
def setup
- build_engine
end
- def test_controllers_are_correctly_namespaced
+ def test_controllers_are_correctly_namespaced_when_engine_is_mountable
+ build_mountable_engine
Dir.chdir(engine_path) do
bundled_rails("g controller topics")
- assert_file "app/controllers/foo_bar/topics_controller.rb", /FooBar::TopicsController/
+ assert_file "app/controllers/foo_bar/topics_controller.rb", /module FooBar\n class TopicsController/
assert_no_file "app/controllers/topics_controller.rb"
end
end
- def test_models_are_correctly_namespaced
+ def test_models_are_correctly_namespaced_when_engine_is_mountable
+ build_mountable_engine
Dir.chdir(engine_path) do
bundled_rails("g model topic")
- assert_file "app/models/foo_bar/topic.rb", /FooBar::Topic/
+ assert_file "app/models/foo_bar/topic.rb", /module FooBar\n class Topic/
assert_no_file "app/models/topic.rb"
end
end
- def test_helpers_are_correctly_namespaced
+ def test_helpers_are_correctly_namespaced_when_engine_is_mountable
+ build_mountable_engine
Dir.chdir(engine_path) do
bundled_rails("g helper topics")
- assert_file "app/helpers/foo_bar/topics_helper.rb", /FooBar::TopicsHelper/
+ assert_file "app/helpers/foo_bar/topics_helper.rb", /module FooBar\n module TopicsHelper/
assert_no_file "app/helpers/topics_helper.rb"
end
end
+
+ def test_controllers_are_not_namespaced_when_engine_is_not_mountable
+ build_engine
+ Dir.chdir(engine_path) do
+ bundled_rails("g controller topics")
+ assert_file "app/controllers/topics_controller.rb", /class TopicsController/
+ assert_no_file "app/controllers/foo_bar/topics_controller.rb"
+ end
+ end
+
+ def test_models_are_not_namespaced_when_engine_is_not_mountable
+ build_engine
+ Dir.chdir(engine_path) do
+ bundled_rails("g model topic")
+ assert_file "app/models/topic.rb", /class Topic/
+ assert_no_file "app/models/foo_bar/topic.rb"
+ end
+ end
+
+ def test_helpers_are_not_namespaced_when_engine_is_not_mountable
+ build_engine
+ Dir.chdir(engine_path) do
+ bundled_rails("g helper topics")
+ assert_file "app/helpers/topics_helper.rb", /module TopicsHelper/
+ assert_no_file "app/helpers/foo_bar/topics_helper.rb"
+ end
+ end
end
end