Skip to content

Commit

Permalink
Don't mutate the parent configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmazza committed Jun 22, 2012
1 parent 402bc5c commit 2715403
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/i18n_alchemy.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ module ClassMethods
def localize(*methods) def localize(*methods)
options = methods.extract_options! options = methods.extract_options!
parser = options[:using] 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 hash[method_name] = parser
end end
self.localized_methods = methods self.localized_methods = self.localized_methods.merge(methods)
end end
end end
end end
Expand Down
1 change: 1 addition & 0 deletions test/db/test_schema.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


create_table :suppliers do |t| create_table :suppliers do |t|
t.string :name t.string :name
t.timestamp :created_at
end end


create_table :accounts do |t| create_table :accounts do |t|
Expand Down
4 changes: 4 additions & 0 deletions test/models/supplier.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ class Supplier < ActiveRecord::Base
accepts_nested_attributes_for :products accepts_nested_attributes_for :products
accepts_nested_attributes_for :account accepts_nested_attributes_for :account
end end

class AnotherSupplier < Supplier
localize :created_at, :using => :timestamp
end
7 changes: 7 additions & 0 deletions test/models_test.rb
Original file line number Original file line Diff line number Diff line change
@@ -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

0 comments on commit 2715403

Please sign in to comment.