Created
July 23, 2010 15:16
-
-
Save ramhoj/487565 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- __send__("#{attribute}=", container.evaluate(self)) | |
+ value = container.evaluate(self) | |
+ value = value.dup if value.duplicable? | |
+ __send__("#{attribute}=", value) | |
changed_attributes.delete(attribute) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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