Sha256: 4e7defcf4970464875b752cbe4bcbc9db2114b06c5b40ce84099e8b2469c14ea
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 KB
Contents
require 'test_helper' require 'models' class BelongsToPolymorphicProxyTest < Test::Unit::TestCase def setup clear_all_collections end should "default to nil" do status = Status.new status.target.should be_nil status.target.inspect.should == "nil" end should "be able to replace the association" do status = Status.new project = Project.new(:name => "mongomapper") status.target = project status.save.should be_true from_db = Status.find(status.id) from_db.target.should_not be_nil from_db.target.inspect.should_not be_empty from_db.target_id.should == project.id from_db.target_type.should == "Project" from_db.target.name.should == "mongomapper" end should "unset the association" do status = Status.new project = Project.new(:name => "mongomapper") status.target = project status.save.should be_true from_db = Status.find(status.id) from_db.target = nil from_db.target_type.should be_nil from_db.target_id.should be_nil from_db.target.should be_nil from_db.target.inspect.should == "nil" end context "association id set but document not found" do setup do @status = Status.new project = Project.new(:name => "mongomapper") @status.target = project @status.save.should be_true project.destroy end should "return nil instead of raising error" do @status.target.should be_nil @status.target.inspect.should == "nil" end end end
Version data entries
4 entries across 4 versions & 1 rubygems