Sha256: 3b608b9c4f0e110da61c1394fd1ca2c7a9013829dca65d743ebb362b2052591a

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

require 'abstract_unit'
require 'fixtures/reference_type'
require 'fixtures/reference_code'

class TestUpdate < Test::Unit::TestCase
  
  CLASSES = {
    :single => {
      :class => ReferenceType,
      :primary_keys => :reference_type_id,
      :update => { :description => 'RT Desc' },
    },
    :dual   => { 
      :class => ReferenceCode,
      :primary_keys => [:reference_type_id, :reference_code],
      :update => { :description => 'RT Desc' },
    },
  }
  
  def setup
    create_fixtures :reference_types, :reference_codes
    self.class.classes = CLASSES
  end
  
  def test_setup
    testing_with do
      assert_not_nil @klass_info[:update]
    end
  end
  
  def test_update_attributes
    testing_with do
      assert @first.update_attributes(@klass_info[:update])
      assert @first.reload
      @klass_info[:update].each_pair do |attr_name, new_value|
        assert_equal new_value, @first[attr_name], "Attribute #{attr_name} is incorrect"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
composite_primary_keys-0.8.0 test/test_update.rb
composite_primary_keys-0.8.2 test/test_update.rb
composite_primary_keys-0.8.4 test/test_update.rb
composite_primary_keys-0.9.0 test/test_update.rb
composite_primary_keys-0.8.6 test/test_update.rb
composite_primary_keys-0.8.5 test/test_update.rb
composite_primary_keys-0.8.3 test/test_update.rb