Sha256: 75d19bea4ded40ca03a4d99720722b644e19f5589be03b3c6787df8e03d9425a

Contents?: true

Size: 832 Bytes

Versions: 3

Compression:

Stored size: 832 Bytes

Contents

require 'test_helper'
require 'models'

class BelongsToProxyTest < Test::Unit::TestCase
  def setup
    clear_all_collections
  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
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
djsun-mongomapper-0.3.1.1 test/functional/associations/test_belongs_to_proxy.rb
djsun-mongomapper-0.3.1 test/functional/associations/test_belongs_to_proxy.rb
jnunemaker-mongomapper-0.3.2 test/functional/associations/test_belongs_to_proxy.rb