Sha256: 827129325926a6bc7a188037d4a13855f9fc09484ee8c74b1b4de3b95de42dff

Contents?: true

Size: 1.85 KB

Versions: 103

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 == 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: '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

103 entries across 103 versions & 1 rubygems

Version Path
forest_liana-4.1.3 test/services/forest_liana/has_many_getter_test.rb
forest_liana-4.1.2 test/services/forest_liana/has_many_getter_test.rb
forest_liana-4.1.1 test/services/forest_liana/has_many_getter_test.rb
forest_liana-4.1.0 test/services/forest_liana/has_many_getter_test.rb
forest_liana-4.0.2 test/services/forest_liana/has_many_getter_test.rb
forest_liana-4.0.1 test/services/forest_liana/has_many_getter_test.rb
forest_liana-4.0.0 test/services/forest_liana/has_many_getter_test.rb
forest_liana-4.0.0.pre.beta.1 test/services/forest_liana/has_many_getter_test.rb
forest_liana-3.3.0 test/services/forest_liana/has_many_getter_test.rb
forest_liana-4.0.0.pre.beta.0 test/services/forest_liana/has_many_getter_test.rb
forest_liana-3.2.0 test/services/forest_liana/has_many_getter_test.rb
forest_liana-3.1.1 test/services/forest_liana/has_many_getter_test.rb
forest_liana-3.1.0 test/services/forest_liana/has_many_getter_test.rb
forest_liana-3.0.7 test/services/forest_liana/has_many_getter_test.rb
forest_liana-3.0.6 test/services/forest_liana/has_many_getter_test.rb
forest_liana-3.0.5 test/services/forest_liana/has_many_getter_test.rb
forest_liana-3.0.4 test/services/forest_liana/has_many_getter_test.rb
forest_liana-3.0.3 test/services/forest_liana/has_many_getter_test.rb
forest_liana-3.0.2 test/services/forest_liana/has_many_getter_test.rb
forest_liana-3.0.1 test/services/forest_liana/has_many_getter_test.rb