Sha256: ac701210e122ccaf5770c93e54bf0f42ea336d7cd6835b50f99c432aedceb1a3

Contents?: true

Size: 964 Bytes

Versions: 62

Compression:

Stored size: 964 Bytes

Contents

require 'test_helper'

module Workarea
  class OrderingTest < TestCase
    class FooParent
      include ApplicationDocument

      embeds_many :foos, class_name: "Workarea::OrderingTest::FooChild"
      embeds_many :foo_fighters, class_name: "Workarea::OrderingTest::FooChild"
    end

    class FooChild
      include ApplicationDocument
      include Ordering

      embedded_in :bar,
        class_name: "Workarea::OrderingTest::FooParent",
        inverse_of: :foos

      embedded_in :bar,
        class_name: "Workarea::OrderingTest::FooParent",
        inverse_of: :foo_fighters
    end

    def test_ordering_embedded_relations
      doc = FooParent.create(
        foos: [
          FooChild.new,
          FooChild.new
        ],
        foo_fighters: [
          FooChild.new,
          FooChild.new
        ],
      )

      assert_equal([0, 1], doc.foos.map(&:position))
      assert_equal([0, 1], doc.foo_fighters.map(&:position))
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/models/workarea/ordering_test.rb
workarea-core-3.5.26 test/models/workarea/ordering_test.rb
workarea-core-3.4.45 test/models/workarea/ordering_test.rb
workarea-core-3.5.25 test/models/workarea/ordering_test.rb
workarea-core-3.5.23 test/models/workarea/ordering_test.rb
workarea-core-3.4.44 test/models/workarea/ordering_test.rb
workarea-core-3.5.22 test/models/workarea/ordering_test.rb
workarea-core-3.4.43 test/models/workarea/ordering_test.rb
workarea-core-3.5.21 test/models/workarea/ordering_test.rb
workarea-core-3.4.42 test/models/workarea/ordering_test.rb
workarea-core-3.5.20 test/models/workarea/ordering_test.rb
workarea-core-3.4.41 test/models/workarea/ordering_test.rb
workarea-core-3.5.19 test/models/workarea/ordering_test.rb
workarea-core-3.4.40 test/models/workarea/ordering_test.rb
workarea-core-3.5.18 test/models/workarea/ordering_test.rb
workarea-core-3.4.39 test/models/workarea/ordering_test.rb
workarea-core-3.5.17 test/models/workarea/ordering_test.rb
workarea-core-3.4.38 test/models/workarea/ordering_test.rb
workarea-core-3.5.16 test/models/workarea/ordering_test.rb
workarea-core-3.4.37 test/models/workarea/ordering_test.rb