aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Wu <ifredwu@gmail.com>2012-06-06 19:02:11 +1000
committerFred Wu <ifredwu@gmail.com>2012-06-06 19:02:11 +1000
commit686966a1861e6761021d45f6795de753e8a62216 (patch)
tree399e60adeaaeffe8cda595648836e1894e408100
parent870310db6a9f3c4ef70831cbc31271d567c90137 (diff)
downloadrails-686966a1861e6761021d45f6795de753e8a62216.tar.gz
rails-686966a1861e6761021d45f6795de753e8a62216.tar.bz2
rails-686966a1861e6761021d45f6795de753e8a62216.zip
Fixed the application_controller require_dependency path generated by the app generator
-rw-r--r--railties/lib/rails/generators/named_base.rb9
-rw-r--r--railties/lib/rails/generators/rails/controller/templates/controller.rb2
-rw-r--r--railties/test/generators/namespaced_generators_test.rb4
3 files changed, 9 insertions, 6 deletions
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index 63703176de..b060b4330b 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -84,10 +84,11 @@ module Rails
end
def namespaced_class_path
- @namespaced_class_path ||= begin
- namespace_path = namespace.name.split("::").map {|m| m.underscore }
- namespace_path + @class_path
- end
+ @namespaced_class_path ||= [namespace_path] + @class_path
+ end
+
+ def namespace_path
+ @namespace_path ||= namespace.name.split("::").map {|m| m.underscore }[0]
end
def class_name
diff --git a/railties/lib/rails/generators/rails/controller/templates/controller.rb b/railties/lib/rails/generators/rails/controller/templates/controller.rb
index 4053113b4b..0f15125649 100644
--- a/railties/lib/rails/generators/rails/controller/templates/controller.rb
+++ b/railties/lib/rails/generators/rails/controller/templates/controller.rb
@@ -1,5 +1,5 @@
<% if namespaced? -%>
-require_dependency "<%= namespaced_file_path %>/application_controller"
+require_dependency "<%= namespace_path %>/application_controller"
<% end -%>
<% module_namespacing do -%>
diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb
index 09169ef2d2..2ae9dc61a7 100644
--- a/railties/test/generators/namespaced_generators_test.rb
+++ b/railties/test/generators/namespaced_generators_test.rb
@@ -38,7 +38,9 @@ class NamespacedControllerGeneratorTest < NamespacedGeneratorTestCase
def test_namespaced_controller_with_additional_namespace
run_generator ["admin/account"]
- assert_file "app/controllers/test_app/admin/account_controller.rb", /module TestApp/, / class Admin::AccountController < ApplicationController/
+ assert_file "app/controllers/test_app/admin/account_controller.rb", /module TestApp/, / class Admin::AccountController < ApplicationController/ do |contents|
+ assert_match %r(require_dependency "test_app/application_controller"), contents
+ end
end
def test_helpr_is_also_namespaced