Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add order note to fulfillment requests when passed on options

  • Loading branch information...
commit af579f696269badab1e37055cc3a0975200e3f04 1 parent 6a43e13
@BlakeMesdag BlakeMesdag authored
View
3  lib/active_fulfillment/fulfillment/services/shipwire.rb
@@ -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
View
13 test/unit/services/shipwire_test.rb
@@ -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>"
Please sign in to comment.
Something went wrong with that request. Please try again.