Sha256: 9c424f8974d0fac952fd125565707d61cef0471962bbf5db6a5970f2b7cd8a0a

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe Spree::Address, type: :model do
  let(:address) { build(:address) }

  describe '#validation_enabled?' do
    it 'returns true if preference is true and country validation is enabled' do
      Spree::Avatax::Config.address_validation = true
      Spree::Avatax::Config.address_validation_enabled_countries = ['United States', 'Canada']

      expect(address.validation_enabled?).to be_truthy
    end

    it 'returns false if address validation preference is false' do
      Spree::Avatax::Config.address_validation = false

      expect(address.validation_enabled?).to be_falsey
    end

    it 'returns false if enabled country is not present' do
      Spree::Avatax::Config.address_validation_enabled_countries = ['Canada']

      expect(address.validation_enabled?).to be_falsey
    end
  end

  describe '#country_validation_enabled?' do
    it 'returns true if the current country is enabled' do
      expect(address.country_validation_enabled?).to be_truthy
    end
  end

  describe '#validation_enabled_countries' do
    it 'returns an array' do
      expect(Spree::Address.validation_enabled_countries).to be_kind_of(Array)
    end

    it 'includes United States' do
      Spree::Avatax::Config.address_validation_enabled_countries = ['United States', 'Canada']

      expect(Spree::Address.validation_enabled_countries).to include('United States')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_avatax_certified-3.0.0 spec/models/spree/address_decorator_spec.rb
solidus_avatax_certified-2.0.0 spec/models/spree/address_decorator_spec.rb
solidus_avatax_certified-1.1.0 spec/models/spree/address_decorator_spec.rb