Skip to content

Commit

Permalink
Merge pull request #4826 from kennyj/fix_4737-2
Browse files Browse the repository at this point in the history
Fix GH #4737. Missing helper file (LoadError) in mountable plugin.
  • Loading branch information
José Valim committed Feb 1, 2012
2 parents d2c6400 + 8afa8b0 commit 6b22889
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ def camelized
end

def valid_const?
if camelized =~ /^\d/
if original_name =~ /[^0-9a-zA-Z_]+/
raise Error, "Invalid plugin name #{original_name}. Please give a name which use only alphabetic or numeric or \"_\" characters."
elsif camelized =~ /^\d/
raise Error, "Invalid plugin name #{original_name}. Please give a name which does not start with numbers."
elsif RESERVED_NAMES.include?(name)
raise Error, "Invalid plugin name #{original_name}. Please give a name which does not match one of the reserved rails words."
Expand Down
15 changes: 8 additions & 7 deletions railties/test/generators/plugin_new_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
include SharedGeneratorTests

def test_invalid_plugin_name_raises_an_error
content = capture(:stderr){ run_generator [File.join(destination_root, "43-things")] }
assert_equal "Invalid plugin name 43-things. Please give a name which does not start with numbers.\n", content
end

def test_invalid_plugin_name_is_fixed
run_generator [File.join(destination_root, "things-43")]
assert_file "things-43/lib/things-43.rb", /module Things43/
content = capture(:stderr){ run_generator [File.join(destination_root, "things-43")] }
assert_equal "Invalid plugin name things-43. Please give a name which use only alphabetic or numeric or \"_\" characters.\n", content

content = capture(:stderr){ run_generator [File.join(destination_root, "things4.3")] }
assert_equal "Invalid plugin name things4.3. Please give a name which use only alphabetic or numeric or \"_\" characters.\n", content

content = capture(:stderr){ run_generator [File.join(destination_root, "43things")] }
assert_equal "Invalid plugin name 43things. Please give a name which does not start with numbers.\n", content
end

def test_camelcase_plugin_name_underscores_filenames
Expand Down

0 comments on commit 6b22889

Please sign in to comment.