Sha256: dfb09ac2f71464c1263a4c2d249524c7ee8c9cf6b104592c2c53833343c19e3f

Contents?: true

Size: 714 Bytes

Versions: 3

Compression:

Stored size: 714 Bytes

Contents

require 'test_helper'

class StiTest < ActiveSupport::TestCase

  def setup
    Forceps.configure
    create_remote_car(name: 'audi')
  end

  test "should instantiate the proper remote record when fetching a record through the parent class" do
    remote_car = Forceps::Remote::Product.find_by_name('audi')
    assert_instance_of Forceps::Remote::Car, remote_car
  end

  test "should download child objects when using single table inheritance" do
    Forceps::Remote::Product.find_by_name('audi').copy_to_local
    assert_not_nil Product.find_by_name('CAR: audi')
  end

  def create_remote_car(attributes)
    RemoteProduct.create!(attributes).tap do |car|
      car.update_column :type, 'Car'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
forceps-0.6.2 test/sti_test.rb
forceps-0.6.1 test/sti_test.rb
forceps-0.6.0 test/sti_test.rb