Sha256: 0d89a73ea33cd1fed8c3b366a79a167ab65d5137bee56568a79c8961e02a1cec

Contents?: true

Size: 655 Bytes

Versions: 2

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true
# encoding: utf-8

require 'spec_helper'

describe 'has_one associations' do
  context 'destroying parent in transaction with dependent child' do
    require_transaction_support

    let(:person) { Person.create! }
    let(:game) { Game.create!(person: person) }

    before do
      Person.delete_all
      Game.delete_all

      game
    end

    it 'works' do
      Person.count.should == 1
      Game.count.should == 1

      Person.with_session do |session|
        session.with_transaction do
          person.destroy
        end
      end

      Person.count.should == 0
      Game.count.should == 0
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongoid-7.1.5 spec/integration/associations/has_one_spec.rb
mongoid-7.1.4 spec/integration/associations/has_one_spec.rb