Sha256: 7b5bf0acefd04f027d87e19e3edc3b81bb7cf7dbd732008d69084fc26eb8f8c7

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'fortnox/api'
require 'fortnox/api/mappers'
require 'fortnox/api/repositories/customer'
require 'fortnox/api/repositories/examples/all'
require 'fortnox/api/repositories/examples/find'
require 'fortnox/api/repositories/examples/save'
require 'fortnox/api/repositories/examples/save_with_specially_named_attribute'
require 'fortnox/api/repositories/examples/search'

describe Fortnox::API::Repository::Customer, order: :defined, integration: true do
  include Helpers::Configuration

  before { set_api_test_configuration }

  subject(:repository) { described_class.new }

  include_examples '.save', :name

  include_examples '.save with specially named attribute',
                   { name: 'Test customer' },
                   :email_invoice_cc,
                   'test@example.com'

  # It is not yet possible to delete Customers. Therefore, expected nr of
  # Customers 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) { { city: 'Not Found' } }
    let(:single_param_find_by_hash) { { find_hash: { city: 'New York' }, matches: 2 } }

    let(:multi_param_find_by_hash) do
      { find_hash: { city: 'New York', zipcode: '10001' }, matches: 1 }
    end
  end

  include_examples '.search', :name, 'Test', 23
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fortnox-api-0.6.3 spec/fortnox/api/repositories/customer_spec.rb
fortnox-api-0.6.2 spec/fortnox/api/repositories/customer_spec.rb
fortnox-api-0.6.1 spec/fortnox/api/repositories/customer_spec.rb
fortnox-api-0.6.0 spec/fortnox/api/repositories/customer_spec.rb