From 503d56aa4103d07651969956c4fa3cb7adf17ff6 Mon Sep 17 00:00:00 2001 From: Luke Rodgers Date: Fri, 24 Jul 2015 12:57:52 -0400 Subject: [PATCH 1/2] Fix timing related specs. These specs seem to have been failing for a long time: I was not able to find a commit where they were passing. --- spec/lib/client_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/lib/client_spec.rb b/spec/lib/client_spec.rb index 78b5dca..7e087df 100644 --- a/spec/lib/client_spec.rb +++ b/spec/lib/client_spec.rb @@ -56,7 +56,7 @@ contacts = client.all(:params => {"updated-min" => "1234"}) contacts.id.should == "john.doe@gmail.com" - contacts.updated.to_s.should == "2012-04-05T21:46:31.537Z" + contacts.updated.to_s.should == "2012-04-05T21:46:31+00:00" contacts.title.should == "Johnny's Contacts" contacts.author.should == {"name" => "Johnny", "email" => "john.doe@gmail.com"} contacts.next_uri.should be_nil @@ -68,7 +68,7 @@ contact = contacts.first contact.id.should == "http://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/base/fd8fb1a55f2916e" contact.title.should == "Steve Stephson" - contact.updated.to_s.should == "2012-02-06T01:14:56.240Z" + contact.updated.to_s.should == "2012-02-06T01:14:56+00:00" contact.edit_uri.should == URI("https://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/full/fd8fb1a55f2916e") contact.etag.should == '"OWUxNWM4MTEzZjEyZTVjZTQ1Mjgy."' contact.data.should == {"gd:name"=>[{"gd:fullName"=>"Steve Stephson", "gd:givenName"=>"Steve", "gd:familyName"=>"Stephson"}], "gd:email"=>[{"@rel"=>"http://schemas.google.com/g/2005#other", "@address"=>"steve.stephson@gmail.com", "@primary"=>"true"}, {"@rel"=>"http://schemas.google.com/g/2005#other", "@address"=>"steve@gmail.com"}], "gd:phoneNumber"=>[{"text"=>"3005004000", "@rel"=>"http://schemas.google.com/g/2005#mobile"}, {"text"=>"+130020003000", "@rel"=>"http://schemas.google.com/g/2005#work"}], "gContact:groupMembershipInfo"=>[{"@deleted"=>"false", "@href"=>"http://www.google.com/m8/feeds/groups/john.doe%40gmail.com/base/6"}]} @@ -78,7 +78,7 @@ contact = contacts[1] contact.id.should == "http://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/base/894bc75ebb5187d" contact.title.should == "Jill Doe" - contact.updated.to_s.should == "2011-07-01T18:08:32.555Z" + contact.updated.to_s.should == "2011-07-01T18:08:32+00:00" contact.edit_uri.should == URI("https://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/full/894bc75ebb5187d") contact.etag.should == '"ZGRhYjVhMTNkMmFhNzJjMzEyY2Ux."' contact.data.should == {"gd:name" => [{"gd:fullName" => "Jill Doe", "gd:givenName" => "Jill", "gd:familyName" => "Doe"}]} @@ -86,7 +86,7 @@ contact = contacts[2] contact.id.should == "http://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/base/cd046ed518f0fb0" contact.title.should == 'Dave "Terry" Pratchett' - contact.updated.to_s.should == "2011-06-29T23:11:57.345Z" + contact.updated.to_s.should == "2011-06-29T23:11:57+00:00" contact.edit_uri.should == URI("https://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/full/cd046ed518f0fb0") contact.etag.should == '"ZWVhMDQ0MWI0MWM0YTJkM2MzY2Zh."' contact.data.should == {"gd:name"=>[{"gd:fullName"=>"Dave \"Terry\" Pratchett", "gd:givenName"=>"Dave", "gd:additionalName"=>"\"Terry\"", "gd:familyName"=>"Pratchett"}], "gd:organization"=>[{"gd:orgName"=>"Foo Bar Inc", "@rel"=>"http://schemas.google.com/g/2005#work"}], "gd:email"=>[{"@rel"=>"http://schemas.google.com/g/2005#home", "@address"=>"dave.pratchett@gmail.com", "@primary"=>"true"}], "gd:phoneNumber"=>[{"text"=>"7003002000", "@rel"=>"http://schemas.google.com/g/2005#mobile"}], "gContact:groupMembershipInfo"=>[{"@deleted"=>"false", "@href"=>"http://www.google.com/m8/feeds/groups/john.doe%40gmail.com/base/6"}]} @@ -96,7 +96,7 @@ contact = contacts[3] contact.id.should == "http://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/base/a1941d3d13cdc66" contact.title.should == "Jane Doe" - contact.updated.to_s.should == "2012-04-04T02:08:37.804Z" + contact.updated.to_s.should == "2012-04-04T02:08:37+00:00" contact.edit_uri.should == URI("https://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/full/a1941d3d13cdc66") contact.etag.should == '"Yzg3MTNiODJlMTRlZjZjN2EyOGRm."' contact.data.should == {"gd:name"=>[{"gd:fullName"=>"Jane Doe", "gd:givenName"=>"Jane", "gd:familyName"=>"Doe"}], "gd:email"=>[{"@rel"=>"http://schemas.google.com/g/2005#home", "@address"=>"jane.doe@gmail.com", "@primary"=>"true"}], "gd:phoneNumber"=>[{"text"=>"16004003000", "@rel"=>"http://schemas.google.com/g/2005#mobile"}], "gd:structuredPostalAddress"=>[{"gd:formattedAddress"=>"5 Market St\n San Francisco\n CA", "gd:street"=>"5 Market St", "gd:city"=>"San Francisco", "gd:region"=>"CA", "@rel"=>"http://schemas.google.com/g/2005#home"}], "gContact:groupMembershipInfo"=>[{"@deleted"=>"false", "@href"=>"http://www.google.com/m8/feeds/groups/john.doe%40gmail.com/base/6"}]} @@ -286,7 +286,7 @@ groups = client.all(:params => {"updated-min" => "1234"}) groups.id.should == "john.doe@gmail.com" - groups.updated.to_s.should == "2012-04-05T22:32:03.192Z" + groups.updated.to_s.should == "2012-04-05T22:32:03+00:00" groups.title.should == "Johnny's Contact Groups" groups.author.should == {"name" => "Johnny", "email" => "john.doe@gmail.com"} groups.next_uri.should be_nil @@ -298,7 +298,7 @@ group = groups.first group.id.should == "http://www.google.com/m8/feeds/groups/john.doe%40gmail.com/base/6" group.title.should == "System Group: My Contacts" - group.updated.to_s.should == "1970-01-01T00:00:00.000Z" + group.updated.to_s.should == "1970-01-01T00:00:00+00:00" group.edit_uri.should be_nil group.etag.should == '"YWJmYzA."' group.data.should have(1).items @@ -306,7 +306,7 @@ group = groups[1] group.id.should == "http://www.google.com/m8/feeds/groups/john.doe%40gmail.com/base/ada43d293fdb9b1" group.title.should == "Misc" - group.updated.to_s.should == "2009-08-17T20:33:20.978Z" + group.updated.to_s.should == "2009-08-17T20:33:20+00:00" group.edit_uri.should == URI("https://www.google.com/m8/feeds/groups/john.doe%40gmail.com/full/ada43d293fdb9b1") group.etag.should == '"QXc8cDVSLyt7I2A9WxNTFUkLRQQ."' group.data.should have(0).items From d09c93d21bc4f60eae8388a33b19c453ba2d18c7 Mon Sep 17 00:00:00 2001 From: Luke Rodgers Date: Fri, 24 Jul 2015 13:38:55 -0400 Subject: [PATCH 2/2] Unescape ampersands from parsed link nodes. Fixes a couple failing specs related to missing parameters in pagination links we construct. --- lib/google-contacts/list.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/google-contacts/list.rb b/lib/google-contacts/list.rb index 7350b3b..f7b2757 100644 --- a/lib/google-contacts/list.rb +++ b/lib/google-contacts/list.rb @@ -30,9 +30,9 @@ def initialize(data=nil) if data["link"] data["link"].each do |link| if link["@rel"] == "next" - @next_uri = URI(link["@href"]) + @next_uri = parse_link(link["@href"]) elsif link["@rel"] == "previous" - @previous_uri = URI(link["@href"]) + @previous_uri = parse_link(link["@href"]) end end end @@ -56,6 +56,10 @@ def [](index); @entries[index] end def empty?; @entries.empty? end def length; @entries.length end + def parse_link(href) + URI(href.gsub(/(&)|(&)/, '&')) + end + alias size length end end