Sha256: b02e96aa0390571e7e69a12931d2406ce29c61f02a03396d08ffda274d7d3f96

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'
require 'fortnox/api'
require 'fortnox/api/mappers'
require 'fortnox/api/repositories/order'
require 'fortnox/api/repositories/examples/all'
require 'fortnox/api/repositories/examples/find'
require 'fortnox/api/repositories/examples/only'
require 'fortnox/api/repositories/examples/save'
require 'fortnox/api/repositories/examples/save_with_nested_model'
require 'fortnox/api/repositories/examples/search'

describe Fortnox::API::Repository::Order, order: :defined, integration: true do
  subject(:repository){ described_class.new }

  required_hash = { customer_number: '1' }

  include_examples '.save', :comments, additional_attrs: required_hash

  nested_model_hash = { price: 10, article_number: '0000', ordered_quantity: 1 }
  include_examples '.save with nested model',
                   required_hash,
                   :order_rows,
                   nested_model_hash,
                   [ Fortnox::API::Types::OrderRow.new( nested_model_hash ) ]

  # It is not possible to delete Orders. Therefore, expected nr of Orders
  # when running .all will continue to increase (until 100, which is max by default).
  include_examples '.all', 100

  include_examples '.find', 1 do
    let( :find_by_hash_failure ){ { ourreference: 'Not found' } }

    let( :single_param_find_by_hash ) do
      { find_hash: { ourreference: 'Belladonna Took' }, matches: 2 }
    end
    let( :multi_param_find_by_hash ) do
      { find_hash: { ourreference: 'Belladonna Took', yourreference: 'Bodo Proudfoot' },
        matches: 1 }
    end
  end

  include_examples '.search', :customername, 'A customer', 2

  include_examples '.only', :cancelled, 3
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fortnox-api-0.4.0 spec/fortnox/api/repositories/order_spec.rb