Sha256: c7f88ae6ae8ee2a42acebfee2ff1399e4020bcb5acfa2180b46fdda0af449d4d

Contents?: true

Size: 1.61 KB

Versions: 2

Compression:

Stored size: 1.61 KB

Contents

require 'helper'
require "test/unit"
require "pp"

# Replace these with your test instance
URL   = "http://valet/sugarcrm"
USER  = "admin"
PASS  = 'letmein' 

class TestSugarcrm < Test::Unit::TestCase
  context "A SugarCRM::Base instance" do
    setup do
      @sugarcrm = SugarCRM::Base.new(URL, USER, PASS, {:debug => true})
    end
    
    should "return a single entry in JSON format when option :to_obj => false" do
      @test = SugarCRM::Base.new(URL, USER, PASS, {:debug => true, :to_obj => false})
      response = @test.get_entry(
        "Users",
        1,
        {:fields => ["first_name", "last_name"]}
      )
      assert_kind_of Hash, response
    end
    
    should "return a single entry when sent #get_entry." do
      response = @sugarcrm.get_entry(
        "Users",
        1,
        {:fields => ["first_name", "last_name"]} 
      )
      assert_respond_to 'response', :entry_list
    end
    
    should "return a list of entries when sent #get_entries." do
      response = @sugarcrm.get_entries(
        "Users",
        [1],
        {:fields => ["first_name", "last_name"]} 
      )
      assert_respond_to 'response', :entry_list
    end
    
    should "return a list of entries when sent #get_entry_list." do
      response = @sugarcrm.get_entry_list(
        "Users",
        "users.user_name = \'#{USER}\'",
        {
          :fields => ["first_name", "last_name"],
          :link_fields => [
            {
              "name"  => "accounts",
              "value" => ["id", "name"]
            }
          ]          
        } 
      )
      assert_respond_to 'response', :entry_list
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sugarcrm-0.5.3 test/test_sugarcrm.rb
sugarcrm-0.5.2 test/test_sugarcrm.rb