diff --git a/lib/couchrest/mixins/validation.rb b/lib/couchrest/mixins/validation.rb index 4b15c01..263b548 100644 --- a/lib/couchrest/mixins/validation.rb +++ b/lib/couchrest/mixins/validation.rb @@ -63,7 +63,9 @@ module CouchRest # share the validations with subclasses def self.inherited(subklass) - subklass.instance_variable_set(:@validations, self.validators.dup) + self.validators.contexts.each do |k, v| + subklass.validators.contexts[k] = v.dup + end end EOS diff --git a/spec/couchrest/more/extended_doc_subclass_spec.rb b/spec/couchrest/more/extended_doc_subclass_spec.rb index b2342b2..8cdede4 100644 --- a/spec/couchrest/more/extended_doc_subclass_spec.rb +++ b/spec/couchrest/more/extended_doc_subclass_spec.rb @@ -42,6 +42,12 @@ describe "Subclassing an ExtendedDocument" do validated_fields.should include(:job_title) end + it "should not add to the parent's validations" do + validated_fields = Card.validators.contexts[:default].map{|v| v.field_name} + validated_fields.should_not include(:extension_code) + validated_fields.should_not include(:job_title) + end + it "should inherit default property values" do @card.bg_color.should == '#ccc' end