Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Single table inheritance validations for belongs_to pass for subclasses when they should not #2

Closed
costi opened this Issue Nov 6, 2011 · 0 comments

Comments

Projects
None yet
1 participant

costi commented Nov 6, 2011

First test passes, second one fails.

require 'rubygems'
require 'data_mapper'

DataMapper.setup(:default, 'sqlite::memory:')

class Address
  include DataMapper::Resource
  property :id, Serial
end

class Person
  include DataMapper::Resource
  property :id, Serial
  belongs_to :address
end

class Man < Person
end

DataMapper.auto_migrate!

describe 'person' do
  it 'requires address' do
    person = Person.new
    person.valid?
    person.errors[:address_id].should include("Address must not be blank")
  end
end

describe 'man' do
  it 'requires address' do
    man = Man.new
    man.valid?
    man.errors[:address_id].should include("Address must not be blank")
  end
end

@costi costi closed this Nov 7, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment