Sha256: 62757e218345a6fac5fcd040804fb128d2693cc55e9f9ad04a9994a4849bb5b0

Contents?: true

Size: 1.33 KB

Versions: 9

Compression:

Stored size: 1.33 KB

Contents

require File.dirname(__FILE__) + '/helper'

class AdministratorTest < Test::Unit::TestCase
  context "when an api caller is authenticated" do
    setup do
      @api_key = '123123123123123123123'
      CreateSend.api_key @api_key
      @admin = CreateSend::Administrator.new "admin@example.com"
    end
    
    should "get a administrator by email address" do
      email = "admin@example.com"
      stub_get(@api_key, "admins.json?email=#{CGI.escape(email)}", "admin_details.json")      
      admin = CreateSend::Administrator.get email
      admin.EmailAddress.should == email
      admin.Name.should == "Admin One"
      admin.Status.should == "Active"
    end

    should "add an administrator" do
      stub_post(@api_key, "admins.json", "add_admin.json")
      result = CreateSend::Administrator.add "admin@example.com", "Admin"
      result.EmailAddress.should == "admin@example.com"
    end

    should "update an administrator" do
      email = "admin@example.com"
      new_email = "new_email_address@example.com"
      stub_put(@api_key, "admins.json?email=#{CGI.escape(email)}", nil)
      @admin.update new_email, "Admin Name"
      @admin.email_address.should == new_email
    end
      
    should "delete an admin" do
      stub_delete(@api_key, "admins.json?email=#{CGI.escape(@admin.email_address)}", nil)
      @admin.delete
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
createsend-2.5.1 test/administrator_test.rb
createsend-2.5.0 test/administrator_test.rb
createsend-2.4.0 test/administrator_test.rb
createsend-2.3.0 test/administrator_test.rb
createsend-2.2.0 test/administrator_test.rb
createsend-2.1.0 test/administrator_test.rb
createsend-2.0.0 test/administrator_test.rb
createsend-1.1.1 test/administrator_test.rb
createsend-1.1.0 test/administrator_test.rb