Created
May 14, 2011 02:34
-
-
Save AquaGeek/971786 to your computer and use it in GitHub Desktop.
Rails Lighthouse ticket #6472
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From c1d878382ca14c516d6cf10c955bb1f6bde93fb4 Mon Sep 17 00:00:00 2001 | |
From: Ilya Zayats <somebody32@gmail.com> | |
Date: Sat, 26 Feb 2011 06:26:36 +0300 | |
Subject: [PATCH] we can now pass actions with colons to the controller generator and it will works correctly | |
--- | |
.../rails/controller/controller_generator.rb | 4 ++++ | |
.../test/generators/controller_generator_test.rb | 5 +++++ | |
2 files changed, 9 insertions(+), 0 deletions(-) | |
diff --git a/railties/lib/rails/generators/rails/controller/controller_generator.rb b/railties/lib/rails/generators/rails/controller/controller_generator.rb | |
index 9788c0d..3b1f1ef 100644 | |
--- a/railties/lib/rails/generators/rails/controller/controller_generator.rb | |
+++ b/railties/lib/rails/generators/rails/controller/controller_generator.rb | |
@@ -3,6 +3,10 @@ module Rails | |
class ControllerGenerator < NamedBase | |
argument :actions, :type => :array, :default => [], :banner => "action action" | |
check_class_collision :suffix => "Controller" | |
+ | |
+ def normalize_actions | |
+ self.actions = actions.map { |action| action.gsub(":", "").gsub(",","") } | |
+ end | |
def create_controller_files | |
template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb") | |
diff --git a/railties/test/generators/controller_generator_test.rb b/railties/test/generators/controller_generator_test.rb | |
index be99dc0..26a65d4 100644 | |
--- a/railties/test/generators/controller_generator_test.rb | |
+++ b/railties/test/generators/controller_generator_test.rb | |
@@ -57,6 +57,11 @@ class ControllerGeneratorTest < Rails::Generators::TestCase | |
run_generator | |
assert_file "config/routes.rb", /get "account\/foo"/, /get "account\/bar"/ | |
end | |
+ | |
+ def test_add_correct_routes_if_not_correct_actions_specified | |
+ run_generator ["account", ":foo,", ":bar"] | |
+ assert_file "config/routes.rb", /get "account\/foo"/, /get "account\/bar"/ | |
+ end | |
def test_invokes_default_template_engine_even_with_no_action | |
run_generator ["account"] | |
-- | |
1.7.4.1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 0f943ee29cca51aca7227ed45f53c10fe216b6f2 Mon Sep 17 00:00:00 2001 | |
From: Ilya Zayats <somebody32@gmail.com> | |
Date: Sat, 26 Feb 2011 07:27:37 +0300 | |
Subject: [PATCH] we can now pass actions with colons or commas to the controller generator and it will work correctly | |
--- | |
.../rails/controller/controller_generator.rb | 4 ++++ | |
.../test/generators/controller_generator_test.rb | 5 +++++ | |
2 files changed, 9 insertions(+), 0 deletions(-) | |
diff --git a/railties/lib/rails/generators/rails/controller/controller_generator.rb b/railties/lib/rails/generators/rails/controller/controller_generator.rb | |
index 9788c0d..4d15f5f 100644 | |
--- a/railties/lib/rails/generators/rails/controller/controller_generator.rb | |
+++ b/railties/lib/rails/generators/rails/controller/controller_generator.rb | |
@@ -3,6 +3,10 @@ module Rails | |
class ControllerGenerator < NamedBase | |
argument :actions, :type => :array, :default => [], :banner => "action action" | |
check_class_collision :suffix => "Controller" | |
+ | |
+ def normalize_actions | |
+ self.actions = actions.map { |action| action.gsub(/:|,/, "") } | |
+ end | |
def create_controller_files | |
template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb") | |
diff --git a/railties/test/generators/controller_generator_test.rb b/railties/test/generators/controller_generator_test.rb | |
index be99dc0..26a65d4 100644 | |
--- a/railties/test/generators/controller_generator_test.rb | |
+++ b/railties/test/generators/controller_generator_test.rb | |
@@ -57,6 +57,11 @@ class ControllerGeneratorTest < Rails::Generators::TestCase | |
run_generator | |
assert_file "config/routes.rb", /get "account\/foo"/, /get "account\/bar"/ | |
end | |
+ | |
+ def test_add_correct_routes_if_not_correct_actions_specified | |
+ run_generator ["account", ":foo,", ":bar"] | |
+ assert_file "config/routes.rb", /get "account\/foo"/, /get "account\/bar"/ | |
+ end | |
def test_invokes_default_template_engine_even_with_no_action | |
run_generator ["account"] | |
-- | |
1.7.4.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment