Skip to content

Commit

Permalink
[FIX][PERSISTENCE] Fixed an error with 'false' as default
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyza committed Dec 1, 2011
1 parent 32bf8d3 commit 12cea4b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/tire/model/persistence/attributes.rb
Expand Up @@ -45,7 +45,7 @@ def property(name, options = {})
define_attribute_methods [name.to_sym]

# Save property default value (when relevant):
if default_value = options.delete(:default)
unless (default_value = options.delete(:default)).nil?
property_defaults[name.to_sym] = default_value
end

Expand Down
3 changes: 2 additions & 1 deletion test/models/persistent_article_with_defaults.rb
Expand Up @@ -4,6 +4,7 @@ class PersistentArticleWithDefaults

property :title
property :published_on
property :tags, :default => []
property :tags, :default => []
property :hidden, :default => false

end
3 changes: 2 additions & 1 deletion test/unit/model_persistence_test.rb
Expand Up @@ -197,7 +197,8 @@ class << a

should "return default value for attribute" do
article = PersistentArticleWithDefaults.new :title => 'Test'
assert_equal [], article.tags
assert_equal [], article.tags
assert_equal false, article.hidden
end

should "have query method for attribute" do
Expand Down

0 comments on commit 12cea4b

Please sign in to comment.