#1481 new
siplux

Throw exceptions with :constraint is defined on both sides of relationship

Reported by siplux | February 2nd, 2011 @ 01:32 AM

The following test fails on 1.9.2 but passes on 1.8.7

    require 'rubygems'
    require 'dm-migrations'
    require 'dm-constraints'
    require 'test/unit'
    require 'shoulda'

    class Article
      include DataMapper::Resource
      property :id,         Serial 
      property :name,       String

      has n, :tasks, :through => Resource, :constraint => :destroy
    end

    class Task
      include DataMapper::Resource
      property :id,         Serial 
      property :name,       String

      has n, :articles, :through => Resource, :constraint => :destroy
    end

    DataMapper.setup(:default, 'mysql://db_admin@localhost/test_db')
    DataMapper.auto_migrate! if defined?(DataMapper)

    class TestDmEvents < Test::Unit::TestCase

      context "Blah" do
        setup do
          @article = Article.create :name => "article"
          %w(foo bar baz quux).each do |name|
            Task.create(:name => name)
          end
          @article.tasks = Task.all
          @article.save
        end
        should "work" do
          assert_same_elements [1,2,3,4], Task.all.map(&:id)
          Task.get(1).destroy
          assert_same_elements [2,3,4], Task.all.map(&:id) # Fails: <{2=>1, 3=>1, 4=>1}> expected but was <{}>.
        end
      end
    end

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Pages