1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix the collision check for the scaffold generator

Fixes #37543
This commit is contained in:
Ryan Robeson 2019-11-05 17:39:02 -05:00
parent bc5d9567be
commit 0d470fb0f1
2 changed files with 9 additions and 1 deletions

View file

@ -213,7 +213,7 @@ module Rails
#
def self.check_class_collision(options = {}) # :doc:
define_method :check_class_collision do
name = if respond_to?(:controller_class_name) # for ResourceHelpers
name = if respond_to?(:controller_class_name, true) # for ResourceHelpers
controller_class_name
else
class_name

View file

@ -303,4 +303,12 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
assert_match(/params\.require\(:message\)\.permit\(:video, photos: \[\]\)/, content)
end
end
def test_check_class_collision
Object.send :const_set, :UsersController, Class.new
content = capture(:stderr) { run_generator }
assert_match(/The name 'UsersController' is either already used in your application or reserved/, content)
ensure
Object.send :remove_const, :UsersController
end
end