Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't mutate the parent configuration

  • Loading branch information...
commit 2715403486ab245847191440305cfe55d41a9809 1 parent 402bc5c
@lucasmazza lucasmazza authored
View
4 lib/i18n_alchemy.rb
@@ -28,10 +28,10 @@ module ClassMethods
def localize(*methods)
options = methods.extract_options!
parser = options[:using]
- methods = methods.each_with_object(localized_methods) do |method_name, hash|
+ methods = methods.each_with_object({}) do |method_name, hash|
hash[method_name] = parser
end
- self.localized_methods = methods
+ self.localized_methods = self.localized_methods.merge(methods)
end
end
end
View
1  test/db/test_schema.rb
@@ -20,6 +20,7 @@
create_table :suppliers do |t|
t.string :name
+ t.timestamp :created_at
end
create_table :accounts do |t|
View
4 test/models/supplier.rb
@@ -7,3 +7,7 @@ class Supplier < ActiveRecord::Base
accepts_nested_attributes_for :products
accepts_nested_attributes_for :account
end
+
+class AnotherSupplier < Supplier
+ localize :created_at, :using => :timestamp
+end
View
7 test/models_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class ModelsTest < I18n::Alchemy::TestCase
+ def test_inheritance_configuration
+ assert Supplier.localized_methods != AnotherSupplier.localized_methods
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.