Skip to content

Instantly share code, notes, and snippets.

@ramhoj
Created July 23, 2010 15:16
Show Gist options
  • Save ramhoj/487565 to your computer and use it in GitHub Desktop.
Save ramhoj/487565 to your computer and use it in GitHub Desktop.
def test_default_values_are_not_changable_by_the_instances_when_dupable
define_model_class do
set_table_name "users"
default_value_for :username, "hello"
end
user1 = TestClass.new
user1.username << " world"
user2 = TestClass.new
assert_equal("hello", user2.username)
end
- __send__("#{attribute}=", container.evaluate(self))
+ value = container.evaluate(self)
+ value = value.dup if value.duplicable?
+ __send__("#{attribute}=", value)
changed_attributes.delete(attribute)
end
end
def test_default_values_are_not_duplicated
define_model_class do
set_table_name "users"
default_value_for :username, "hello"
end
user1 = TestClass.new
user1.username << " world"
user2 = TestClass.new
assert_equal("hello world", user2.username)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment