Sha256: 9065244c9f2ba3bfa4ed3e2c1aac2c71403798b824b596ed8edd016305c476a8

Contents?: true

Size: 823 Bytes

Versions: 1

Compression:

Stored size: 823 Bytes

Contents

require 'test_helper'

class AssociationTest < ActiveSupport::TestCase

  test 'accessor' do
    apple = shops(:apple)
    assert_equal 'iPhone,iPad', apple.product_list

    imac = Product.new(name: 'iMac')
    apple.expects(:product_added).never
    apple.expects(:product_removed).never
    apple.products << imac
    assert_equal 'iPhone,iPad,iMac', apple.product_list
    assert_equal [], apple.added_products_to_list
    assert_equal [], apple.removed_products_from_list

    apple.expects(:product_added).once.with('MacBook')
    apple.expects(:product_removed).once.with('iPad')
    apple.product_list = 'iMac,iPhone,MacBook'
    assert_equal 'iPhone,iMac,MacBook', apple.product_list
    assert_equal ['MacBook'], apple.added_products_to_list
    assert_equal ['iPad'], apple.removed_products_from_list
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
listable_collections-0.0.1 test/association_test.rb