Skip to content
This repository
Browse code

Merge pull request #4826 from kennyj/fix_4737-2

Fix GH #4737. Missing helper file (LoadError) in mountable plugin.
  • Loading branch information...
commit 6b22889bd8950e6d0cfad29db0e425a731067a46 2 parents d2c6400 + 8afa8b0
José Valim josevalim authored
4 railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
@@ -285,7 +285,9 @@ def camelized
285 285 end
286 286
287 287 def valid_const?
288   - if camelized =~ /^\d/
  288 + if original_name =~ /[^0-9a-zA-Z_]+/
  289 + raise Error, "Invalid plugin name #{original_name}. Please give a name which use only alphabetic or numeric or \"_\" characters."
  290 + elsif camelized =~ /^\d/
289 291 raise Error, "Invalid plugin name #{original_name}. Please give a name which does not start with numbers."
290 292 elsif RESERVED_NAMES.include?(name)
291 293 raise Error, "Invalid plugin name #{original_name}. Please give a name which does not match one of the reserved rails words."
15 railties/test/generators/plugin_new_generator_test.rb
@@ -27,13 +27,14 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
27 27 include SharedGeneratorTests
28 28
29 29 def test_invalid_plugin_name_raises_an_error
30   - content = capture(:stderr){ run_generator [File.join(destination_root, "43-things")] }
31   - assert_equal "Invalid plugin name 43-things. Please give a name which does not start with numbers.\n", content
32   - end
33   -
34   - def test_invalid_plugin_name_is_fixed
35   - run_generator [File.join(destination_root, "things-43")]
36   - assert_file "things-43/lib/things-43.rb", /module Things43/
  30 + content = capture(:stderr){ run_generator [File.join(destination_root, "things-43")] }
  31 + assert_equal "Invalid plugin name things-43. Please give a name which use only alphabetic or numeric or \"_\" characters.\n", content
  32 +
  33 + content = capture(:stderr){ run_generator [File.join(destination_root, "things4.3")] }
  34 + assert_equal "Invalid plugin name things4.3. Please give a name which use only alphabetic or numeric or \"_\" characters.\n", content
  35 +
  36 + content = capture(:stderr){ run_generator [File.join(destination_root, "43things")] }
  37 + assert_equal "Invalid plugin name 43things. Please give a name which does not start with numbers.\n", content
37 38 end
38 39
39 40 def test_camelcase_plugin_name_underscores_filenames

0 comments on commit 6b22889

Please sign in to comment.
Something went wrong with that request. Please try again.