mirror of
https://github.com/github/rails.git
synced 2026-01-10 07:07:54 -05:00
Do not in place modify what table_name returns
This commit is contained in:
@@ -107,7 +107,7 @@ module ActiveModel
|
||||
sing.send :define_method, name, &block
|
||||
else
|
||||
value = value.to_s if value
|
||||
sing.send(:define_method, name) { value && value.dup }
|
||||
sing.send(:define_method, name) { value }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,10 +9,6 @@ class ModelWithAttributes
|
||||
define_method(:bar) do
|
||||
'original bar'
|
||||
end
|
||||
|
||||
define_method(:zomg) do
|
||||
'original zomg'
|
||||
end
|
||||
end
|
||||
|
||||
def attributes
|
||||
@@ -102,13 +98,6 @@ class AttributeMethodsTest < ActiveModel::TestCase
|
||||
assert_equal "value of foo bar", ModelWithAttributesWithSpaces.new.send(:'foo bar')
|
||||
end
|
||||
|
||||
def test_defined_methods_always_return_duped_string
|
||||
ModelWithAttributes.define_attr_method(:zomg, 'lol')
|
||||
assert_equal 'lol', ModelWithAttributes.zomg
|
||||
ModelWithAttributes.zomg << 'bbq'
|
||||
assert_equal 'lol', ModelWithAttributes.zomg
|
||||
end
|
||||
|
||||
test '#define_attr_method generates attribute method' do
|
||||
ModelWithAttributes.define_attr_method(:bar, 'bar')
|
||||
|
||||
|
||||
@@ -995,7 +995,7 @@ module ActiveRecord #:nodoc:
|
||||
if parent < ActiveRecord::Base && !parent.abstract_class?
|
||||
contained = parent.table_name
|
||||
contained = contained.singularize if parent.pluralize_table_names
|
||||
contained << '_'
|
||||
contained += '_'
|
||||
end
|
||||
"#{full_table_name_prefix}#{contained}#{undecorated_table_name(name)}#{table_name_suffix}"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user