notahat/machinist — Issue #104: Incompatible with presence validation on associated record
Author: coreyward
Created: 2012-01-08 20:43:15+00:00
State: open

It looks like the way Machinist works doesn't make it possible to do the following:

class Post
has_many :comments
end

class Comment
belongs_to :post
validates :post_id, :presence => true
end

Comment.blueprint do
post
end

describe Comment do
it 'is valid when generated by Machinist' do
Comment.make.should be_valid
end
end

When I try this my test fails with the presence validation error on `Comment.post_id`.

I've temporarily worked around this by disabling this validation, but I prefer enforcing this so I have fewer orphan records lingering about.