Permalink
Browse files

fix signature option

  • Loading branch information...
1 parent 90fc362 commit ba1c7a55ca0934b621735cdda2569c5693b0853e @binarylogic committed Aug 21, 2010
@@ -97,6 +97,24 @@ def build_package(b)
b.Units package_dimension_units
end
end
+
+ if respond_to?(:signature) && signature
+ self.special_services_requested << "SIGNATURE_OPTION"
+ end
+
+ if (respond_to?(:special_services_requested) && special_services_requested.any?)
+ b.SpecialServicesRequested do
+ if special_services_requested.any?
+ b.SpecialServiceTypes special_services_requested.join(",")
+ end
+
+ if signature
+ b.SignatureOptionDetail do
+ b.OptionType signature
+ end
+ end
+ end
+ end
end
end
@@ -181,20 +181,6 @@ def build_request
build_authentication(b)
build_version(b, "ship", VERSION[:major], VERSION[:intermediate], VERSION[:minor])
- if special_services_requested.any? || signature
- b.SpecialServicesRequested do
- if special_services_requested.any?
- b.SpecialServiceTypes special_services_requested.join(",")
- end
-
- if signature
- b.SignatureOptionDetail do
- b.OptionType signature
- end
- end
- end
- end
-
b.RequestedShipment do
b.ShipTimestamp ship_time.xmlschema if ship_time
b.DropoffType dropoff_type if dropoff_type
@@ -1,7 +1,7 @@
module Shippinglogic
class Proxy
alias_method :real_class, :class
- instance_methods.each { |m| undef_method m unless m =~ /^(__|real_class$|send$|object_id$)/ }
+ instance_methods.each { |m| undef_method m unless m =~ /^(__|real_class$|send$|object_id|respond_to\?$)/ }
attr_accessor :target

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -28,4 +28,10 @@
# exactly the same as shipping, and that works just fine. You would think a multi
# billion dollar company would have decent web services.
end
+
+ it "should allow set the signature option" do
+ use_response(:ship_with_no_signature)
+ @shipment.signature = "NO_SIGNATURE_REQUIRED"
+ @shipment.rate.should == 35.53
+ end
end
@@ -4,6 +4,7 @@
Spec::Runner.configure do |config|
config.before(:each) do
+ HTTParty::Request.response_directory = File.dirname(__FILE__) + "/responses"
FakeWeb.clean_registry
if File.exists?("#{SPEC_ROOT}/fedex/responses/_new.xml")
View
@@ -1,9 +1,13 @@
module HTTParty
class Request
+ class << self
+ attr_accessor :response_directory
+ end
+
def perform_actual_request
response = http.request(@raw_request)
if !defined?(DONT_SAVE) && !FakeWeb.registered_uri?(:post, uri)
- File.open(File.dirname(__FILE__) + "/../responses/_new.xml", 'w') {|f| f.write(response.body) }
+ File.open(self.class.response_directory + "/_new.xml", 'w') {|f| f.write(response.body) }
raise FakeWeb::NetConnectNotAllowedError.new("You have not registered this response, the response has been put in responses/_new.xml")
else
response

0 comments on commit ba1c7a5

Please sign in to comment.