Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add default value to an attribute description.

RM bug: there is no BS for the model's properties, which means a boolean
property will return 0/1 instead of false/true.
  • Loading branch information...
commit 7b5992eef562ce1733a1c2159398f4da44e03a24 1 parent e023c10
@alloy authored
Showing with 11 additions and 3 deletions.
  1. +1 −0  app/schema.rb
  2. +10 −3 spec/managed_object_spec.rb
View
1  app/schema.rb
@@ -60,6 +60,7 @@ def self.withReflection(reflection)
ad = new
ad.attributeReflection = reflection
ad.name = reflection[:name]
+ ad.defaultValue = reflection[:options][:default]
ad.optional = !reflection[:options][:required]
type = reflection[:type]
View
13 spec/managed_object_spec.rb
@@ -27,12 +27,17 @@ module MotionData
Author.new.class.entityDescription.managedObjectClassName.should == 'Author'
end
- describe "property types" do
+ describe "property definitions" do
it "includes String support" do
author = Author.new
author.name = "Edgar Allan Poe"
author.name.should == "Edgar Allan Poe"
end
+
+ it "by default uses the default value" do
+ Article.new.published.should == false
+ Article.new(:published => true).published.should == true
+ end
end
describe "initialization" do
@@ -66,7 +71,7 @@ module MotionData
Author.edgars.predicate.predicateFormat.should == 'name == "edgar"'
end
- it "extends the normal Core Data realtionship set to act like a Scope::Relationship" do
+ it "extends the normal Core Data relationship set to act like a Scope::Relationship" do
author = Author.new
author.articles.should.is_a? Scope::Relationship::SetExt
author.articles.__scope__.owner.should == author
@@ -74,7 +79,9 @@ module MotionData
article1 = author.articles.new(:title => 'article1')
article2 = author.articles.new(:title => 'article2')
- author.articles.withTitle.to_a.should == [article2, article1]
+ author.articles.published.withTitle.to_a.should == []
+ article1.published = true; article2.published = true
+ author.articles.published.withTitle.to_a.should == [article2, article1]
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.