Sha256: 07ae49963ccbad4734fcdf9ae2aafbbe9530440957484f4f0318e4a99fb9c7d7

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

module ForestLiana
  describe Collection do
    before do
      allow(ForestLiana).to receive(:env_secret).and_return(nil)
    end

    let(:collection) { ForestLiana.apimap.select { |collection| collection.name == 'Address' }.first }

    describe 'field' do
      it 'add simple smart field' do
        field = collection.fields.select { |field| field[:field] == :address_type }.first

        expect(field).not_to be_nil
        expect(field).to eq(
          {
            type: "String",
            is_read_only: true,
            is_required: false,
            default_value: nil,
            integration: nil,
            reference: nil,
            inverse_of: nil,
            relationships: nil,
            widget: nil,
            validations: [],
            is_virtual: true,
            field: :address_type,
            is_filterable: false,
            is_sortable: false
          }
        )
      end

      it 'add polymorphic smart field with default values' do
        field = collection.fields.select { |field| field[:field] == :addressable_id }.first

        expect(field).not_to be_nil
        expect(field[:is_filterable]).to eq(true)
        expect(field[:is_sortable]).to eq(true)
      end

      it 'add polymorphic smart field with is_filterable option set to false' do
        field = collection.fields.select { |field| field[:field] == :addressable_type }.first

        expect(field).not_to be_nil
        expect(field[:is_filterable]).to eq(false)
        expect(field[:is_sortable]).to eq(true)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
forest_liana-9.7.0 spec/lib/forest_liana/collection_spec.rb
forest_liana-9.6.4 spec/lib/forest_liana/collection_spec.rb
forest_liana-9.6.3 spec/lib/forest_liana/collection_spec.rb
forest_liana-9.6.0 spec/lib/forest_liana/collection_spec.rb