Skip to content

Commit

Permalink
Add support for using global env_namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
walle authored and rubiii committed Apr 5, 2011
1 parent e1bd487 commit 3710136
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
16 changes: 16 additions & 0 deletions lib/savon/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ def strip_namespaces?
# Sets whether to strip namespaces in a SOAP response Hash.
attr_writer :strip_namespaces

# Returns the current action_converter
attr_reader :converter

# Sets both action_converter and input_converter, converter should be a proc.
def converter=(converter)
@converter = converter
end

# Returns the global env_namespace.
attr_reader :env_namespace

# Sets the global env_namespace.
def env_namespace=(namespace)
@env_namespace = namespace
end

# Reset to default configuration.
def reset_config!
self.log = true
Expand Down
5 changes: 3 additions & 2 deletions lib/savon/soap/xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def header
# Sets the SOAP envelope namespace.
attr_writer :env_namespace

# Returns the SOAP envelope namespace. Defaults to :env.
# Returns the SOAP envelope namespace. Uses the global namespace if set Defaults to :env.
def env_namespace
@env_namespace ||= :env
@env_namespace ||= Savon.env_namespace.nil? ? :env : Savon.env_namespace
end

# Sets the +namespaces+ Hash.
Expand Down Expand Up @@ -181,3 +181,4 @@ def body_to_xml
end
end
end

8 changes: 7 additions & 1 deletion spec/savon/soap/xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@
xml.env_namespace = :soapenv
xml.env_namespace.should == :soapenv
end

it "should use the global env_namespace if set as the SOAP envelope namespace" do
Savon.stubs(:env_namespace).returns(:soapenv)
xml.env_namespace.should == :soapenv
end
end

describe "#namespaces" do
Expand Down Expand Up @@ -223,7 +228,7 @@
:token => "secret",
:attributes! => { :token => { :xmlns => "http://example.com" } }
}

xml.to_xml.should include('<env:Header><token xmlns="http://example.com">secret</token></env:Header>')
end
end
Expand Down Expand Up @@ -333,3 +338,4 @@ def reset_soap_version
end

end

0 comments on commit 3710136

Please sign in to comment.