Sha256: 1df49f0e5895733aeed696d6bd26c7e433384c768f077d130cb9a52b6707e657

Contents?: true

Size: 1.85 KB

Versions: 57

Compression:

Stored size: 1.85 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: 'America/Nome'
      })
      getter.perform
      records = getter.records
      count = getter.count

      assert records.count == 3
      assert count = 3
      assert records.first.id == 7
    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: 'America/Nome'
      })
      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: 'America/Nome'
      })
      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

57 entries across 57 versions & 1 rubygems

Version Path
forest_liana-6.6.3 test/services/forest_liana/has_many_getter_test.rb
forest_liana-7.0.0.beta.4 test/services/forest_liana/has_many_getter_test.rb
forest_liana-7.0.0.beta.3 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.6.2 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.6.1 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.6.0 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.5.1 test/services/forest_liana/has_many_getter_test.rb
forest_liana-7.0.0.beta.2 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.5.0 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.4.1 test/services/forest_liana/has_many_getter_test.rb
forest_liana-7.0.0.beta.1 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.4.0 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.3.8 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.3.7 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.3.6 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.3.5 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.3.4 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.3.3 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.3.2 test/services/forest_liana/has_many_getter_test.rb
forest_liana-6.3.1 test/services/forest_liana/has_many_getter_test.rb