Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3604

Add test for persisting inverse keys for HABTM substitution

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Setup

       
      class Post
        include Mongoid::Document
      
        has_and_belongs_to_many :tags
      end
      
      class Tag
        include Mongoid::Document
      
        has_and_belongs_to_many :posts
      end
      
      tag = Tag.create
      post = Post.create(tags: [tag])
      post.tags = [Tag.last]
      

      Expected Behavior

      post.reload.tag_ids #=> [tag.id]
      tags.reload.post_ids #=> [post.id]
      

      Actual Behavior

      post.reload.tag_ids #=> [tag.id]
      tag.reload.post_ids #=> []
      

      Commit has a failing test in the many_to_many_spec.rb, but we aren't sure how to fix with out breaking other functionality.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            ersatzryan ersatzryan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: