Sha256: 41bcc19ee295f0fc399b601ef023b01ee3108bc6dcf5242cb3b142b5738645ca

Contents?: true

Size: 1.01 KB

Versions: 5

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

5 entries across 5 versions & 1 rubygems

Version Path
composite_primary_keys-0.3.1 test/update_test.rb
composite_primary_keys-0.6.0 test/update_test.rb
composite_primary_keys-0.3.2 test/update_test.rb
composite_primary_keys-0.3.3 test/update_test.rb
composite_primary_keys-0.6.1 test/update_test.rb