test/subscriber_test.rb in createsend-0.2.1 vs test/subscriber_test.rb in createsend-0.3.0

- old
+ new

@@ -32,9 +32,27 @@ stub_post(@api_key, "subscribers/#{@list_id}.json", "add_subscriber.json") custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ] email_address = CreateSend::Subscriber.add @list_id, "subscriber@example.com", "Subscriber", custom_fields, true email_address.should == "subscriber@example.com" end + + should "add a subscriber with custom fields including multi-option fields" do + stub_post(@api_key, "subscribers/#{@list_id}.json", "add_subscriber.json") + custom_fields = [ { :Key => 'multioptionselectone', :Value => 'myoption' }, + { :Key => 'multioptionselectmany', :Value => 'firstoption' }, + { :Key => 'multioptionselectmany', :Value => 'secondoption' } ] + email_address = CreateSend::Subscriber.add @list_id, "subscriber@example.com", "Subscriber", custom_fields, true + email_address.should == "subscriber@example.com" + end + + should "update a subscriber with custom fields" do + email = "subscriber@example.com" + new_email = "new_email_address@example.com" + stub_put(@api_key, "subscribers/#{@list_id}.json?email=#{CGI.escape(email)}", nil) + custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ] + @subscriber.update new_email, "Subscriber", custom_fields, true + @subscriber.email_address.should == new_email + end should "import many subscribers at once" do stub_post(@api_key, "subscribers/#{@list_id}/import.json", "import_subscribers.json") subscribers = [ { :EmailAddress => "example+1@example.com", :Name => "Example One" }, \ No newline at end of file