Sha256: a718c43b4f035546da7883d722f4ed2cd0e3b11f879e2208c26d33f6cb8c181c

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

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

class UpdateTest < Test::Unit::TestCase
  fixtures :reference_types, :reference_codes
  
  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
    super
    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

8 entries across 8 versions & 1 rubygems

Version Path
composite_primary_keys-0.6.3 test/update_test.rb
composite_primary_keys-0.7.0 test/update_test.rb
composite_primary_keys-0.7.1 test/update_test.rb
composite_primary_keys-0.6.2 test/update_test.rb
composite_primary_keys-0.7.3 test/update_test.rb
composite_primary_keys-0.7.4 test/update_test.rb
composite_primary_keys-0.7.5 test/update_test.rb
composite_primary_keys-0.7.2 test/update_test.rb