Sha256: 1c7b27f476cfd441a071026190d7ce98357873d1bfe13c9d76f787452bb2ad34

Contents?: true

Size: 1.42 KB

Versions: 31

Compression:

Stored size: 1.42 KB

Contents

require 'test_helper'

class OrderTest < Test::Unit::TestCase
  def setup
    ActiveResource::Base.site = "http://localhost"
  end

  context "Order" do
    context "#note_attributes" do

      should "be loaded correctly from order xml" do
        order_xml = <<-XML
          <?xml version="1.0" encoding="UTF-8"?>
          <order>
            <note-attributes type="array">
              <note-attribute>
                <name>size</name>
                <value>large</value>
              </note-attribute>
            </note-attributes>
          </order>
        XML

        order = ShopifyAPI::Order.new(Hash.from_xml(order_xml)["order"])

        assert_equal 1, order.note_attributes.size

        note_attribute = order.note_attributes.first
        assert_equal "size", note_attribute.name
        assert_equal "large", note_attribute.value
      end
      
      should "be able to add note attributes to an order" do
        order = ShopifyAPI::Order.new
        order.note_attributes = []
        order.note_attributes << ShopifyAPI::NoteAttribute.new(:name => "color", :value => "blue")
        
        order_xml = Hash.from_xml(order.to_xml)
        assert note_attributes = order_xml["order"]["note_attributes"]
        assert_instance_of Array, note_attributes
        
        attribute = note_attributes.first
        assert_equal "color", attribute["name"]
        assert_equal "blue", attribute["value"]
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
shopify_api-3.2.1 test/order_test.rb
shopify_api-3.2.0 test/order_test.rb
shopify_api-3.1.8 test/order_test.rb
shopify_api-3.1.7 test/order_test.rb
shopify_api-3.1.6 test/order_test.rb
shopify_api-3.1.5 test/order_test.rb
shopify_api-3.1.3 test/order_test.rb
shopify_api-3.1.2 test/order_test.rb
shopify_api-3.0.3 test/order_test.rb
shopify_api-3.0.2 test/order_test.rb
shopify_api-3.0.1 test/order_test.rb
shopify_api-3.0.0 test/order_test.rb
shopify_api-2.3.0 test/order_test.rb
shopify_api-2.2.0 test/order_test.rb
shopify_api-2.1.0 test/order_test.rb
shopify_api-2.0.0 test/order_test.rb
th_shopify_api-1.2.6.pre test/order_test.rb
shopify_api-1.2.5 test/order_test.rb
shopify_api-1.2.2 test/order_test.rb
shopify_api-1.2.1 test/order_test.rb