Browse files

Add order note to fulfillment requests when passed on options

  • Loading branch information...
1 parent 6a43e13 commit af579f696269badab1e37055cc3a0975200e3f04 @BlakeMesdag BlakeMesdag committed Sep 6, 2012
Showing with 16 additions and 0 deletions.
  1. +3 −0 lib/active_fulfillment/fulfillment/services/shipwire.rb
  2. +13 −0 test/unit/services/shipwire_test.rb
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>"

0 comments on commit af579f6

Please sign in to comment.