Sha256: 175acf918b485ac5a9ef3469f8190d3ad59c839321f88ebf22d5f97434f5888f

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

require File.join(File.dirname(__FILE__), '../../test_helper.rb')

class RecordAssociationTest < Test::Unit::TestCase
  include TestHelper

  def setup
    @client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
    @client.stubs(:http_get).with {|client, url, params| url =~ /Invoices\/[^\/]+$/ }.returns(get_record_xml(:invoice))
    @client.stubs(:http_get).with {|client, url, params| url =~ /Invoices$/ }.returns(get_record_xml(:invoices))
  end
  
  context "belongs_to association" do
    
    should "auto-load complete record if summary" do
      invoice = @client.Invoice.first
      assert_nil(invoice.attributes[:contact].contact_status)
      assert_equal(false, invoice.complete_record_downloaded?)
      assert_not_nil(invoice.contact.contact_status)
      assert_equal(true, invoice.complete_record_downloaded?)
    end
    
  end
  
  context "has_many association" do
    
    should "auto-load complete records if summary" do
      invoice = @client.Invoice.first
      assert_nil(invoice.attributes[:line_items])
      assert_equal(false, invoice.complete_record_downloaded?)
      assert(invoice.line_items.size > 0, "There should be one or more line items.")
      assert_equal(true, invoice.complete_record_downloaded?)
    end
    
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
xeroizer-0.2.2 test/unit/record/record_association_test.rb
xeroizer-0.2.1 test/unit/record/record_association_test.rb
xeroizer-0.2.0 test/unit/record/record_association_test.rb
xeroizer-0.1.3 test/unit/record/record_association_test.rb
xeroizer-0.1.2 test/unit/record/record_association_test.rb
xeroizer-0.1.0 test/unit/record/record_association_test.rb