Sha256: 23cf79d07669091a6af256c08c4530177d9583bba3146deeb59aa7a2269b101c

Contents?: true

Size: 1.49 KB

Versions: 17

Compression:

Stored size: 1.49 KB

Contents

require 'test_helper'

class Gecko::VariantTest < Minitest::Test
  include VCRHelper
  include SharedRecordExamples

  let(:plural_name)   { 'variants' }
  let(:record_class)  { Gecko::Record::Variant }

  def setup
    @json   = load_vcr_hash('variants', 'variants').first
    @record = record_class.new(client, @json)
  end

  def test_initializes_record
    assert_instance_of(Gecko::Record::Variant, @record)
  end

  def test_blank_display_name
    record = record_class.new(client, {})
    assert_equal(record.display_name, "")
  end

  def test_variant_prices
    json = {variant_prices: [{price_list_id: "buy", value: "12.50"}, {price_list_id: 123, value: "14.00"}]}
    variant_prices = record_class.new(client, json).variant_prices
    assert_instance_of(Gecko::Record::Variant::VariantPrice, variant_prices.first)
    assert_equal(variant_prices[0].price_list_id, "buy")
    assert_equal(variant_prices[1].price_list_id, "123")
    assert_equal(variant_prices[1].value, 14.0)
  end

  def test_variant_locations
    json = {locations: [
      { location_id: 1, stock_on_hand: "12.50",
        committed: "0", bin_location: "AB-123" },
    ]}

    locations = record_class.new(client, json).locations
    assert_instance_of(Gecko::Record::Variant::VariantLocation, locations.first)
    assert_equal(1,        locations[0].location_id)
    assert_equal(12.5,     locations[0].stock_on_hand)
    assert_equal(0,        locations[0].committed_stock)
    assert_equal("AB-123", locations[0].bin_location)
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
gecko-ruby-0.9.1 test/record/variant_test.rb
gecko-ruby-0.9.0 test/record/variant_test.rb
gecko-ruby-0.8.0 test/record/variant_test.rb
gecko-ruby-0.2.6 test/record/variant_test.rb
gecko-ruby-0.7.1 test/record/variant_test.rb
gecko-ruby-0.7.0 test/record/variant_test.rb
gecko-ruby-0.6.0 test/record/variant_test.rb
gecko-ruby-0.5.0 test/record/variant_test.rb
gecko-ruby-0.2.5 test/record/variant_test.rb
gecko-ruby-0.2.4 test/record/variant_test.rb
gecko-ruby-0.2.3 test/record/variant_test.rb
gecko-ruby-0.2.2 test/record/variant_test.rb
gecko-ruby-0.2.0 test/record/variant_test.rb
gecko-ruby-0.1.0 test/record/variant_test.rb
gecko-ruby-0.0.10 test/record/variant_test.rb
gecko-ruby-0.0.9 test/record/variant_test.rb
gecko-ruby-0.0.8 test/record/variant_test.rb