Sha256: c3bf1d9a18cbdf153813d937120be742293204f51ed96dec3d8b8ae56e1c800e

Contents?: true

Size: 1.83 KB

Versions: 17

Compression:

Stored size: 1.83 KB

Contents

module ForestLiana
  class HasManyGetterTest < ActiveSupport::TestCase

    collectionOwner = ForestLiana::Model::Collection.new({
      name: 'Owner',
      fields: []
    })

    collectionTree = ForestLiana::Model::Collection.new({
      name: 'Tree',
      fields: []
    })

    ForestLiana.apimap << collectionOwner
    ForestLiana.apimap << collectionTree
    ForestLiana.models << Owner
    ForestLiana.models << Tree

    test 'HasMany Getter page 1 size 15' do
      association = Owner.reflect_on_association(:trees)

      getter = HasManyGetter.new(Owner, association, {
        id: 1,
        association_name: 'trees',
        page: { size: 15, number: 1 },
        timezone: '-08:00'
      })
      getter.perform
      records = getter.records
      count = getter.count

      assert records.count == 3
      assert count = 3
      assert records.first.id == 1
    end

    test 'HasMany Getter with sort parameter' do
      association = Owner.reflect_on_association(:trees)

      getter = HasManyGetter.new(Owner, association, {
        id: 1,
        association_name: 'trees',
        sort: '-id',
        page: { size: 15, number: 1 },
        timezone: '-08:00'
      })
      getter.perform
      records = getter.records
      count = getter.count

      assert records.count == 3
      assert count = 3
      assert records.first.id == 8
    end

    test 'HasMany Getter with search parameter' do
      association = Owner.reflect_on_association(:trees)

      getter = HasManyGetter.new(Owner, association, {
        id: 1,
        association_name: 'trees',
        search: 'Fir',
        page: { size: 15, number: 1 },
        timezone: '-08:00'
      })
      getter.perform
      records = getter.records
      count = getter.count

      assert records.count == 1
      assert count = 1
      assert records.first.id == 8
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
forest_liana-2.5.0 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.4.9 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.4.8 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.4.7 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.4.6 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.4.5 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.4.4 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.4.3 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.4.2 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.4.1 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.4.0 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.3.5 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.3.4 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.3.3 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.3.2 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.3.1 test/services/forest_liana/has_many_getter_test.rb
forest_liana-2.3.0 test/services/forest_liana/has_many_getter_test.rb