test/client_test.rb in createsend-2.2.0 vs test/client_test.rb in createsend-2.3.0
- old
+ new
@@ -12,11 +12,11 @@
should "create a client" do
stub_post(@api_key, "clients.json", "create_client.json")
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")
cl = @client.details
cl.ApiKey.should == "639d8cc27198202f5fe6037a8b17a29a59984b86d3289bc9"
cl.BasicDetails.ClientID.should == "4a397ccaaa55eb4e6aa1221e1e2d7122"
@@ -105,10 +105,16 @@
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 "unsuppress an email address" do
+ email = "example@example.com"
+ stub_put(@api_key, "clients/#{@client.client_id}/unsuppress.json?email=#{CGI.escape(email)}", nil)
+ result = @client.unsuppress email
+ 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"
@@ -145,29 +151,38 @@
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 (implicit)" do
stub_put(@api_key, "clients/#{@client.client_id}/setmonthlybilling.json", nil)
@client.set_monthly_billing "CAD", true, 150
request = FakeWeb.last_request.body
- assert_equal("{\"Currency\":\"CAD\",\"ClientPays\":true,\"MarkupPercentage\":150,\"MonthlyScheme\":null}", request, "Request wasn't as expected")
+ request.include?("\"Currency\":\"CAD\"").should == true
+ request.include?("\"ClientPays\":true").should == true
+ request.include?("\"MarkupPercentage\":150").should == true
+ request.include?("\"MonthlyScheme\":null").should == true
end
should "set monthly billing (basic)" do
stub_put(@api_key, "clients/#{@client.client_id}/setmonthlybilling.json", nil)
@client.set_monthly_billing "CAD", true, 150, "Basic"
request = FakeWeb.last_request.body
- assert_equal("{\"Currency\":\"CAD\",\"ClientPays\":true,\"MarkupPercentage\":150,\"MonthlyScheme\":\"Basic\"}", request, "Request wasn't as expected")
+ request.include?("\"Currency\":\"CAD\"").should == true
+ request.include?("\"ClientPays\":true").should == true
+ request.include?("\"MarkupPercentage\":150").should == true
+ request.include?("\"MonthlyScheme\":\"Basic\"").should == true
end
should "set monthly billing (unlimited)" do
stub_put(@api_key, "clients/#{@client.client_id}/setmonthlybilling.json", nil)
@client.set_monthly_billing "CAD", false, 120, "Unlimited"
request = FakeWeb.last_request.body
- assert_equal("{\"Currency\":\"CAD\",\"ClientPays\":false,\"MarkupPercentage\":120,\"MonthlyScheme\":\"Unlimited\"}", request, "Request wasn't as expected")
+ request.include?("\"Currency\":\"CAD\"").should == true
+ request.include?("\"ClientPays\":false").should == true
+ request.include?("\"MarkupPercentage\":120").should == true
+ request.include?("\"MonthlyScheme\":\"Unlimited\"").should == true
end
should "delete a client" do
stub_delete(@api_key, "clients/#{@client.client_id}.json", nil)
@client.delete