Persistance inconsistency

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • 7.0.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
              Reporter:
              Olivier Milla
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: