Sha256: 817b0c8a4b3ffe9a360602926554d803b05423625e8269c21a5cd49e5dab312c

Contents?: true

Size: 1.89 KB

Versions: 52

Compression:

Stored size: 1.89 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

52 entries across 52 versions & 1 rubygems

Version Path
rock_rms-9.14.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.13.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.12.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.11.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.10.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.9.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.8.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.7.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.6.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.5.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.4.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.3.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.2.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.1.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-9.0.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-8.23.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-8.22.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-8.21.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-8.20.0 spec/rock_rms/resources/attribute_spec.rb
rock_rms-8.19.0 spec/rock_rms/resources/attribute_spec.rb