diff --git a/lib/hoptoad/v2.rb b/lib/hoptoad/v2.rb
index 14a8ea6..524d8cf 100644
--- a/lib/hoptoad/v2.rb
+++ b/lib/hoptoad/v2.rb
@@ -18,6 +18,8 @@ module Hoptoad
{normalize_key(node['key']) => rekey(node['__content__'])}
elsif node.has_key?('__content__')
rekey(node['__content__'])
+ elsif node.has_key?('key')
+ {normalize_key(node['key']) => nil}
else
node.inject({}) {|rekeyed, (key, val)| rekeyed.merge(normalize_key(key) => rekey(val))}
end
diff --git a/spec/controllers/notices_controller_spec.rb b/spec/controllers/notices_controller_spec.rb
index 893cdf5..5a96971 100644
--- a/spec/controllers/notices_controller_spec.rb
+++ b/spec/controllers/notices_controller_spec.rb
@@ -24,6 +24,36 @@ describe NoticesController do
response.body.should match(%r{]*>(.+)#{locate_path(@notice.id)}})
end
+ it "should trnasform xml tags to hashes correctly" do
+ App.should_receive(:report_error!).with(@xml).and_return(@notice)
+ request.should_receive(:raw_post).and_return(@xml)
+ post :create, :format => :xml
+
+ # XML:
+ @notice.env_vars.should have_key('SCRIPT_NAME')
+ @notice.env_vars['SCRIPT_NAME'].should be_nil # blank ends up nil
+
+ # XML representation:
+ #
+ # false
+ # true
+ # /
+ #
+ #
+ #
+ #
+ expected = {
+ 'secure' => 'false',
+ 'httponly' => 'true',
+ 'path' => '/',
+ 'expire_after' => nil,
+ 'domain' => nil,
+ 'id' => nil
+ }
+ @notice.env_vars.should have_key('rack_session_options')
+ @notice.env_vars['rack_session_options'].should eql(expected)
+ end
+
it "generates a notice from xml in a data param [POST]" do
App.should_receive(:report_error!).with(@xml).and_return(@notice)
post :create, :data => @xml, :format => :xml
--
libgit2 0.21.2