Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/active_fulfillment/fulfillment/services/shipwire.rb
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions test/unit/services/shipwire_test.rb
Expand Up @@ -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>"
Expand Down