From 151ea5566d872c8a4887add2c6e77f2aa79bd1f3 Mon Sep 17 00:00:00 2001 From: Tim Heighes Date: Fri, 26 Feb 2010 00:25:51 +0100 Subject: [PATCH] Fixes for 4 of the original 10 failing specs --- lib/couchrest/mixins/properties.rb | 4 ++++ spec/couchrest/more/property_spec.rb | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/couchrest/mixins/properties.rb b/lib/couchrest/mixins/properties.rb index 21e9ca2..bfd6f15 100644 --- a/lib/couchrest/mixins/properties.rb +++ b/lib/couchrest/mixins/properties.rb @@ -58,6 +58,10 @@ module CouchRest key = self.has_key?(property.name) ? property.name : property.name.to_sym # Don't cast the property unless it has a value next if (value = self[key]).nil? + # Don't cast the property if it is not accessible + if self.class.respond_to? :accessible_properties + next if self.class.accessible_properties.index(key).nil? + end write_property(property, value) end end diff --git a/spec/couchrest/more/property_spec.rb b/spec/couchrest/more/property_spec.rb index a98e1a9..9156795 100644 --- a/spec/couchrest/more/property_spec.rb +++ b/spec/couchrest/more/property_spec.rb @@ -175,8 +175,9 @@ describe "ExtendedDocument properties" do @course['participants'].should eql([{}, 'q', 1]) end - it "should cast end_date to Date" do - @event['end_date'].should be_an_instance_of(Date) + it "should cast started_on to Date" do + @course.started_on = Date.today + @course['started_on'].should be_an_instance_of(Date) end end