Sha256: 3e8a059f3b101aefec83bd9db6d3905680e0640bac3e43649a14e97d91caafe4

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

require 'helper'

class TestAssociations < Test::Unit::TestCase
  context "A SugarCRM::Base instance" do
    should "return an email address when sent #email_addresses" do
      u = SugarCRM::User.find("seed_sarah_id")
      assert_equal "sarah@example.com", u.email_addresses.first.email_address
    end
    
    should "utilize the association cache" do
      u = SugarCRM::User.find(1)
      u.email_addresses
      assert u.association_cached? :email_addresses
    end
    
    should "permit adding a record to an association collection (such as #meetings << Meeting.new)" do
      u = SugarCRM::User.find(1)
      m = SugarCRM::Meeting.new
      m.date_start = DateTime.now
      m.duration_hours = 0.5
      m.name = "Yet Another Stupid Meeting"
      u.meetings << m
      assert u.meetings.include?(m)
      assert_equal [m], u.meetings.added
      assert u.save!
      u = SugarCRM::User.find(1)
      assert u.meetings.include?(m)
      assert u.meetings.delete(m)
      assert u.meetings.save!
      assert !u.meetings.include?(m)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sugarcrm-0.9.6 test/test_associations.rb
sugarcrm-0.9.5 test/test_associations.rb
sugarcrm-0.9.4 test/test_associations.rb
sugarcrm-0.9.3 test/test_associations.rb
sugarcrm-0.9.2 test/test_associations.rb
sugarcrm-0.9.1 test/test_associations.rb
sugarcrm-0.9.0 test/test_associations.rb