Sha256: 68c24e826a16c6153d24dbed5804be431445fc721ce828eb6df3f0e5c3114a2e
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
require 'test_helper' require 'models' class BelongsToProxyTest < Test::Unit::TestCase def setup Status.collection.clear Project.collection.clear end should "default to nil" do status = Status.new status.project.should be_nil end should "be able to replace the association" do status = Status.new project = Project.new(:name => "mongomapper") status.project = project status.save.should be_true from_db = Status.find(status.id) from_db.project.should_not be_nil from_db.project.name.should == "mongomapper" end should "unset the association" do status = Status.new project = Project.new(:name => "mongomapper") status.project = project status.save.should be_true from_db = Status.find(status.id) from_db.project = nil from_db.project.should be_nil end context "association id set but document not found" do setup do @status = Status.new(:name => 'Foo', :project_id => '1234') end should "return nil instead of raising error" do @status.project.should be_nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems