Sha256: c3cb2cbaff33cec53e94a57f85a98de5614ef1722f5c88bbbb5fcedaa6b12822

Contents?: true

Size: 1.84 KB

Versions: 56

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'

RSpec.describe RockRMS::Client::Attribute, type: :model do
  include_context 'resource specs'

  describe '#list_attributes' do
    it 'returns a array' do
      resource = client.list_attributes
      expect(resource).to be_a(Array)
      expect(resource.first).to be_a(Hash)
    end
  end

  describe '#create_attribute' do
    context 'arguments' do
      it 'require `field_type_id`' do
        expect { client.create_attribute }
          .to raise_error(ArgumentError, /field_type_id/)
      end

      it 'require `entity_type_id`' do
        expect { client.create_attribute }
          .to raise_error(ArgumentError, /entity_type_id/)
      end

      it 'require `key`' do
        expect { client.create_attribute }
          .to raise_error(ArgumentError, /key/)
      end

      it 'require `name`' do
        expect { client.create_attribute }
          .to raise_error(ArgumentError, /name/)
      end
    end

    subject(:resource) do
      client.create_attribute(
        key: 'TransactionFee',
        name: 'Transaction Fee',
        entity_type_id: 85,
        field_type_id: 14,
        description: 'Transaction fees for a specific gateway',
        order: 1234
      )
    end

    it 'returns integer' do
      expect(resource).to be_a(Integer)
    end

    it 'passes options' do
      expect(client).to receive(:post)
        .with(
          'Attributes',
          'FieldTypeId' => 14,
          'EntityTypeId' => 85,
          'Key' => 'TransactionFee',
          'Name' => 'Transaction Fee',
          'Description' => 'Transaction fees for a specific gateway',
          'Order' => 1234,
          'IsSystem'     => false,
          'IsGridColumn' => false,
          'IsMultiValue' => false,
          'IsRequired'   => false,
          'AllowSearch'  => false
        )
        .and_call_original
      resource
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
rock_rms-6.2.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-6.1.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-6.0.8 spec/rock_rms/resources/attribute_spec.rb
rock_rms-6.0.7 spec/rock_rms/resources/attribute_spec.rb
rock_rms-6.0.6 spec/rock_rms/resources/attribute_spec.rb
rock_rms-6.0.5 spec/rock_rms/resources/attribute_spec.rb
rock_rms-6.0.4 spec/rock_rms/resources/attribute_spec.rb
rock_rms-6.0.3 spec/rock_rms/resources/attribute_spec.rb
rock_rms-6.0.1 spec/rock_rms/resources/attribute_spec.rb
rock_rms-6.0.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-5.18.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-5.17.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-5.16.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-5.15.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-5.14.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-5.13.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-5.12.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-5.11.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-5.10.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-5.9.2 spec/rock_rms/resources/attribute_spec.rb