test/client_test.rb in createsend-1.1.1 vs test/client_test.rb in createsend-2.0.0

- old
+ new

@@ -9,11 +9,11 @@ @client.client_id.should == '321iuhiuhi1u23hi2u3' end should "create a client" do stub_post(@api_key, "clients.json", "create_client.json") - client_id = CreateSend::Client.create "Client Company Name", "Client Contact Name", "client@example.com", "(GMT+10:00) Canberra, Melbourne, Sydney", "Australia" + client_id = CreateSend::Client.create "Client Company Name", "(GMT+10:00) Canberra, Melbourne, Sydney", "Australia" client_id.should == "32a381c49a2df99f1d0c6f3c112352b9" end should "get details of a client" do stub_get(@api_key, "clients/#{@client.client_id}.json", "client_details.json") @@ -66,11 +66,22 @@ lists = @client.lists lists.size.should == 2 lists.first.ListID.should == 'a58ee1d3039b8bec838e6d1482a8a965' lists.first.Name.should == 'List One' end - + + should "get all lists to which a subscriber with a particular email address belongs" do + email = "valid@example.com" + stub_get(@api_key, "clients/#{@client.client_id}/listsforemail.json?email=#{CGI.escape(email)}", "listsforemail.json") + lists = @client.lists_for_email(email) + lists.size.should == 2 + lists.first.ListID.should == 'ab4a2b57c7c8f1ba62f898a1af1a575b' + lists.first.ListName.should == 'List Number One' + lists.first.SubscriberState.should == 'Active' + lists.first.DateSubscriberAdded.should == '2012-08-20 22:32:00' + end + should "get all segments for a client" do stub_get(@api_key, "clients/#{@client.client_id}/segments.json", "segments.json") segments = @client.segments segments.size.should == 2 segments.first.ListID.should == 'a58ee1d3039b8bec838e6d1482a8a965' @@ -92,11 +103,11 @@ res.Results.first.SuppressionReason.should == "Unsubscribed" res.Results.first.EmailAddress.should == "example+1@example.com" res.Results.first.Date.should == "2010-10-26 10:55:31" res.Results.first.State.should == "Suppressed" end - + should "get all people" do stub_get(@api_key, "clients/#{@client.client_id}/people.json", "people.json") people = @client.people people.size.should == 2 people.first.EmailAddress.should == "person1@blackhole.com" @@ -110,43 +121,38 @@ templates = @client.templates templates.size.should == 2 templates.first.TemplateID.should == '5cac213cf061dd4e008de5a82b7a3621' templates.first.Name.should == 'Template One' end - + should "set primary contact" do email = 'person@blackhole.com' stub_put(@api_key, "clients/#{@client.client_id}/primarycontact.json?email=#{CGI.escape(email)}", 'client_set_primary_contact.json') result = @client.set_primary_contact email result.EmailAddress.should == email end - + should "get primary contact" do stub_get(@api_key, "clients/#{@client.client_id}/primarycontact.json", 'client_get_primary_contact.json') result = @client.get_primary_contact result.EmailAddress.should == 'person@blackhole.com' end - + should "set basics" do stub_put(@api_key, "clients/#{@client.client_id}/setbasics.json", nil) - @client.set_basics "Client Company Name", "Client Contact Name", "client@example.com", "(GMT+10:00) Canberra, Melbourne, Sydney", "Australia" + @client.set_basics "Client Company Name", "(GMT+10:00) Canberra, Melbourne, Sydney", "Australia" end - - should "set access" do - stub_put(@api_key, "clients/#{@client.client_id}/setaccess.json", nil) - @client.set_access "username", "password", 321 - end - + should "set payg billing" do stub_put(@api_key, "clients/#{@client.client_id}/setpaygbilling.json", nil) @client.set_payg_billing "CAD", true, true, 150 end - + should "set monthly billing" do stub_put(@api_key, "clients/#{@client.client_id}/setmonthlybilling.json", nil) @client.set_monthly_billing "CAD", true, 150 end - + should "delete a client" do stub_delete(@api_key, "clients/#{@client.client_id}.json", nil) @client.delete end