Sha256: 832a5a700813bf7724f9363c33fe7c88d6631c35376d62cc3f68ac9dcc9fafc0

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require  File.dirname(__FILE__) + '/joinfix_test_helper'

#
# has many test
#

class HasManyMigration < ActiveRecord::Migration
  def self.up
	create_table :hm_parents do |t|
		t.column :field, :string
	end	
	create_table :hm_children do |t|
		t.column :field, :string
		t.column :hm_parent_id, :integer
	end	
  end

  def self.down
	drop_table :hm_parents
	drop_table :hm_children
  end
end

class HmParent < ActiveRecord::Base
	has_many :hm_children
end

class HmChild < ActiveRecord::Base
end

class HasManyTest < Test::Unit::TestCase
	fixtures :hm_parents, :hm_children

	def test_has_many
		setup_fixtures(
:hm_parents  => %Q{
parent_entry:
 field: parent value
 hm_children:
   - child_one:
       field: one
   - child_two:
       field: two},
:hm_children => "")

		assert_fixtures(
:hm_parents  => %Q{
parent_entry:
  id: 1
  field: parent value},
:hm_children => %Q{
child_one:
  id: 1
  hm_parent_id: 1
  field: one
child_two:
  id: 2
  hm_parent_id: 1
  field: two})
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
joinfix-0.1.1 test/has_many_test.rb