Sha256: 0aa00e82e18ba4836e2bfcef3f3e6055b42efe5797fc5dc5be02bc1cbc592797
Contents?: true
Size: 1.65 KB
Versions: 50
Compression:
Stored size: 1.65 KB
Contents
require 'test_helper' class OneEmbeddedProxyTest < Test::Unit::TestCase def setup @post_class = Doc('Post') do key :title, String end @author_class = EDoc('Author') do key :name, String embedded_in :post end end should "default to nil" do @post_class.one :author, :class => @author_class @post_class.new.author.should be_nil end should "be able to build" do @post_class.one :author, :class => @author_class post = @post_class.create author = post.author.build(:name => "John") post.author.should be_instance_of(@author_class) post.author.should be_new post.author.name.should == 'John' post.author.should == author post.author.post.should == post end should "be able to replace the association" do @post_class.one :author, :class => @author_class post = @post_class.new author = @author_class.new(:name => 'Frank') post.author = author post.save post.reload post.author.should == author post.author.nil?.should be_false new_author = @author_class.new(:name => 'Emily') post.author = new_author post.author.should == new_author end should "not have problem loading root document if embedded one is nil" do @post_class.one :author, :class => @author_class post = @post_class.create lambda { @post_class.find(post.id) }.should_not raise_error end should "have boolean method for testing presence" do @post_class.one :author, :class => @author_class post = @post_class.new post.author?.should be_false post.author = @author_class.new(:name => 'Frank') post.author?.should be_true end end
Version data entries
50 entries across 50 versions & 3 rubygems