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

Persistance inconsistency

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

      Hello,
      Is this a desired behavior to have:

      class House
      include Mongoid::Document
      has_many :windows
      end

      class Window
      include Mongoid::Document
      belongs_to :house
      end

      and

      it 'adds windows to the relation' do
      house = House.new
      house.save!
      window = Window.new(:house => house)
      expect(house.windows).to include window
      end

      it 'adds windows to the relation' do
      house = House.new
      house.save!
      window = Window.new
      house.windows << window
      expect(house.windows).to include window
      end

      to both pass yet,

      it 'persists windows' do
      house = House.new
      house.save!
      expect

      { house.windows << Window.new }

      .to change(Window, :count).by(1)
      end

      passes and

      it 'persists windows' do
      house = House.new
      house.save!
      expect

      { Window.new(:house => house) }

      .to change(Window, :count).by(1)
      end

      fails ?

            Assignee:
            Unassigned Unassigned
            Reporter:
            muichkine Olivier Milla
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: