Sha256: 9e485a07bee3c64454ea17e8d0f879fa4e0c0b7be285b9286c2b86598e4a6aba
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
require File.expand_path('../abstract_unit', __FILE__) # Testing the find action on composite ActiveRecords with two primary keys class TestNestedAttributes < ActiveSupport::TestCase fixtures :reference_types def setup @reference_type = ReferenceType.first end def test_nested_atttribute_create code_id = 1001 @reference_type.update_attribute :reference_codes_attributes, [{ :reference_code => code_id, :code_label => 'XX', :abbreviation => 'Xx' }] assert_not_nil ReferenceCode.find_by_reference_code(code_id) end def test_nested_atttribute_update code_id = 1002 @reference_type.update_attribute :reference_codes_attributes, [{ :reference_code => code_id, :code_label => 'XX', :abbreviation => 'Xx' }] reference_code = ReferenceCode.find_by_reference_code(code_id) cpk = CompositePrimaryKeys::CompositeKeys[@reference_type.reference_type_id, code_id] @reference_type.update_attribute :reference_codes_attributes, [{ :id => cpk, :code_label => 'AAA', :abbreviation => 'Aaa' }] reference_code = ReferenceCode.find_by_reference_code(code_id) assert_kind_of(ReferenceCode, reference_code) assert_equal(reference_code.code_label, 'AAA') end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
composite_primary_keys-5.0.12 | test/test_nested_attributes.rb |
composite_primary_keys-5.0.11 | test/test_nested_attributes.rb |