Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

change uuid spec and test

  • Loading branch information...
commit a4681bbc952febfed06acb5ed3ecab95e21eeea7 1 parent ffe321e
eugene gilburg authored
View
2  lib/active_record_mixin.rb
@@ -89,7 +89,7 @@ def sdata_node_name(entity=self.class)
def resource_header_attributes(resource, included)
hash = {"xlmns:sdata:key" => resource.id, "xlmns:sdata:url" => resource.sdata_resource_url}
hash.merge!("xlmns:sdata:descriptor" => resource.entry_content) if included.include?("$descriptor")
- hash.merge!("xlmns:sdata:uuid" => resource.uuid.to_s) if resource.respond_to?("uuid")
+ hash.merge!("xlmns:sdata:uuid" => resource.uuid.to_s) if resource.respond_to?("uuid") && !resource.uuid.blank?
hash
end
View
12 lib/route_mapper.rb
@@ -1,8 +1,8 @@
module SData
class RouteMapper < Struct.new(:router, :resource_name, :options)
def map_sdata_routes!
+ #RADAR: the order of the below statements makes a difference
map_sdata_collection
-
map_sdata_collection_with_condition_and_predicate
map_sdata_collection_with_predicate
map_sdata_collection_with_condition
@@ -26,19 +26,9 @@ def self.urlize(string)
def map_sdata_collection
map_route "#{name_in_path}", 'sdata_collection', :get
end
-
- # FIXME: Should be abstracted to:
- # map_route "#{name_in_path}\/{:condition,([$](linked))}", 'sdata_collection', :get
- # because we will need to support other variables than $linked. However, this conflicts with the route
- # mapping at map_sdata_collection_with_predicate_and_condition. If both methods are abstracted, one of them
- # won't work (the one that won't work depends on which one was mapped first).
- # Furthermore, map_sdata_collection_with_predicate_and_condition method's route causes THIS method's
- # route to magically assign :conditions => '$linked' in params (doesn't happen if $linked is replaced with
- # $anything_else in this method. This is very strange and can be a blocker to supporting further variables.
# http://localhost:3000/sdata/billingboss/crmErp/-/tradingAccounts/$linked
def map_sdata_collection_with_condition
- # map_route "#{name_in_path}\/$linked", 'sdata_collection', :get
map_route "#{name_in_path}\/#{CONDITION}", 'sdata_collection', :get
end
View
13 test/unit/active_record_mixin/payload_spec.rb
@@ -257,10 +257,21 @@ def payload_header_assertions(xml)
element.attributes.collect{|x|x[0]}.sort.should == ["sdata:descriptor", "sdata:key", "sdata:url", "sdata:uuid"]
element.attributes['sdata:descriptor'].value.should == "Contact #123: Contact Name"
when 'crmErp:myContacts'
+ found_with_uuid, found_without_uuid = false
+ element.children.size.should == 2
element.children.each do |child_element|
- child_element.attributes.collect{|x|x[0]}.sort.should == ["sdata:descriptor", "sdata:key", "sdata:url", "sdata:uuid"]
+ if child_element.attributes['sdata:uuid']
+ found_with_uuid = true
+ child_element.attributes.collect{|x|x[0]}.sort.should == ["sdata:descriptor", "sdata:key", "sdata:url", "sdata:uuid"]
+ child_element.attributes['sdata:uuid'].value.should == "C-123-456"
+ else
+ found_without_uuid = true
+ child_element.attributes.collect{|x|x[0]}.sort.should == ["sdata:descriptor", "sdata:key", "sdata:url"]
+ end
child_element.attributes['sdata:descriptor'].value.should =~ /Contact ##{child_element.attributes['sdata:key'].value}.*/
end
+ found_with_uuid.should == true
+ found_without_uuid.should == true
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.