ref: refs/heads/master
commit 7debbe743868ca9405dc7b8c64fe509d7dff5b22
Author: Duncan Mac-Vicar P
Date: Wed Jul 8 16:23:26 2009 +0200
fix problem with statu.xml instead of status, add testcase
---
webclient/lib/yast/service_resource.rb | 4 +-
webclient/test/unit/yast/service_resource_test.rb | 44 ++++++++++++++++++++-
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/webclient/lib/yast/service_resource.rb b/webclient/lib/yast/service_resource.rb
index fd2946e..45b15de 100644
--- a/webclient/lib/yast/service_resource.rb
+++ b/webclient/lib/yast/service_resource.rb
@@ -100,7 +100,9 @@ module YaST
#
# See: https://rails.lighthouseapp.com/projects/8994/tickets/2608-activeresource-su...
def self.fix_singleton_proxy(obj)
- obj.collection_name = obj.element_name.singularize
+ # singularize only if the name is plural
+ obj.collection_name = obj.collection_name.singularize if ( obj.collection_name == obj.collection_name.pluralize)
+ #end
def obj.element_path(id, prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
diff --git a/webclient/test/unit/yast/service_resource_test.rb b/webclient/test/unit/yast/service_resource_test.rb
index 719c536..54d4edc 100644
--- a/webclient/test/unit/yast/service_resource_test.rb
+++ b/webclient/test/unit/yast/service_resource_test.rb
@@ -54,6 +54,7 @@ EOF
</foo>
</foos>
EOF
+
@foo_response = "<foo><bar>Bye</bar></foo>"
@master_response = "<master><name>He-Man</name></master>"
# simulate that we are logged to a service
@@ -212,5 +213,46 @@ FIN
assert Array, c.cities.class
end
-
+ def test_proxy_works_with_status_page
+ @status_response = <5.9948777472e+08
+ 6.0554035200e+08
+ 6.0168527872e+08
+ </value>
+ </memoryused>
+ </memory>
+</status>
+EOFA
+
+ @resources_status_response = <
+ <resource>
+ <interface>org.yast.status</interface>
+ <singular type="boolean">true</singular>
+ <href>/status</href>
+ </resource>
+ </resources>
+EOFB
+
+ ActiveResource::HttpMock.respond_to do |mock|
+ mock.put "/status.xml", {}, nil, 200
+ mock.get "/status.xml", {}, @status_response
+ mock.get "/resources.xml", {}, @resources_status_response
+ end
+
+ @proxy = YaST::ServiceResource.proxy_for("org.yast.status")
+ # the proxy is an anonymous class
+ assert @proxy.singular?
+ c = @proxy.find
+ # only one
+ assert_not_equal c.class, Array
+ assert_equal c.memory.memoryused.value.t_1246965000, "6.0168527872e+08"
+ #c.save
+ #c.destroy
+ end
+
end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org