Sha256: 595bc149f015cdbb6cc8286f96de06c52a6d5c32f7e41dae799b6af30112e2d1

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'
require 'fortnox/api/models/invoice'
require 'fortnox/api/validators/context'
require 'fortnox/api/validators/invoice'

describe Fortnox::API::Validator::Invoice do
  let( :model_class ){ Fortnox::API::Model::Invoice }

  subject{ described_class.new }

  include_context 'validator context' do
    let( :valid_model ){ model_class.new( customer_number: 12345 ) }
  end

  describe '.validate Invoice' do
    include_examples 'required attributes', Fortnox::API::Model::Invoice

    include_examples 'validates length of string', :address1, 1024
    include_examples 'validates length of string', :address2, 1024
    include_examples 'validates length of string', :customer_name, 1024
    include_examples 'validates length of string', :external_invoice_reference1, 80
    include_examples 'validates length of string', :external_invoice_reference2, 80
    include_examples 'validates length of string', :our_reference, 50
    include_examples 'validates length of string', :phone1, 1024
    include_examples 'validates length of string', :phone2, 1024
    include_examples 'validates length of string', :remarks, 1024
    include_examples 'validates length of string', :your_order_number, 30
    include_examples 'validates length of string', :your_reference, 50
    include_examples 'validates length of string', :zip_code, 1024

    include_examples 'validates inclusion of number', :administration_fee, 0, 99_999_999_999.0
    include_examples 'validates inclusion of number', :currency_rate, 0, 999_999_999_999_999.0
    include_examples 'validates inclusion of number', :currency_unit, 0, 999_999_999_999_999.0
    include_examples 'validates inclusion of number', :freight, 0, 99_999_999_999.0
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fortnox-api-0.1.0 spec/fortnox/api/validators/invoice_spec.rb