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.4.27 test/models/workarea/ordering_test.rb
workarea-core-3.5.4 test/models/workarea/ordering_test.rb
workarea-core-3.4.26 test/models/workarea/ordering_test.rb
workarea-core-3.5.3 test/models/workarea/ordering_test.rb
workarea-core-3.4.25 test/models/workarea/ordering_test.rb
workarea-core-3.5.2 test/models/workarea/ordering_test.rb
workarea-core-3.4.24 test/models/workarea/ordering_test.rb
workarea-core-3.5.1 test/models/workarea/ordering_test.rb
workarea-core-3.4.23 test/models/workarea/ordering_test.rb
workarea-core-3.4.22 test/models/workarea/ordering_test.rb
workarea-core-3.5.0 test/models/workarea/ordering_test.rb
workarea-core-3.4.21 test/models/workarea/ordering_test.rb
workarea-core-3.5.0.beta.1 test/models/workarea/ordering_test.rb
workarea-core-3.4.20 test/models/workarea/ordering_test.rb
workarea-core-3.4.19 test/models/workarea/ordering_test.rb
workarea-core-3.4.18 test/models/workarea/ordering_test.rb
workarea-core-3.4.17 test/models/workarea/ordering_test.rb
workarea-core-3.4.16 test/models/workarea/ordering_test.rb
workarea-core-3.4.15 test/models/workarea/ordering_test.rb
workarea-core-3.4.14 test/models/workarea/ordering_test.rb