Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add order note if present for Shipwire fulfillments #15

Merged
merged 1 commit into from Sep 6, 2012
Jump to file or symbol
Failed to load files and symbols.
+16 −0
Split
@@ -133,6 +133,9 @@ def add_order(xml, order_id, shipping_address, line_items, options)
Array(line_items).each_with_index do |line_item, index|
add_item(xml, line_item, index)
end
+ xml.tag! 'Note' do
+ xml.cdata! options[:note] unless options[:note].blank?
+ end
end
end
@@ -157,6 +157,19 @@ def test_company_name_in_request
assert_equal 'MyCorp', company_node.text
end
+ def test_order_excludes_note_by_default
+ xml = REXML::Document.new(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
+ note_node = REXML::XPath.first(xml, "//Note").cdatas.first
+ assert_nil note_node
+ end
+
+ def test_order_includes_note_when_present
+ @options[:note] = "A test note"
+ xml = REXML::Document.new(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
+ note_node = REXML::XPath.first(xml, "//Note").cdatas.first
+ assert_equal "A test note", note_node.to_s
+ end
+
private
def successful_empty_tracking_response
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n<TrackingUpdateResponse><Status>Test</Status><TotalOrders></TotalOrders><TotalShippedOrders></TotalShippedOrders><TotalProducts></TotalProducts><Bookmark></Bookmark></TrackingUpdateResponse>"