Sha256: dc04ab116317367522b9c632924ef7cf7c6b9e0d5af9f87dbeb17305a13a99f4

Contents?: true

Size: 1022 Bytes

Versions: 12

Compression:

Stored size: 1022 Bytes

Contents

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

class TestUpdate < ActiveSupport::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
    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

12 entries across 12 versions & 3 rubygems

Version Path
kovyrin-composite_primary_keys-2.3.2 test/test_update.rb
composite_primary_keys-3.0.9 test/test_update.rb
composite_primary_keys-3.0.8 test/test_update.rb
composite_primary_keys-3.0.7 test/test_update.rb
composite_primary_keys-3.0.4 test/test_update.rb
composite_primary_keys-3.0.3 test/test_update.rb
composite_primary_keys-3.0.0.b3 test/test_update.rb
composite_primary_keys-3.0.0.b2 test/test_update.rb
globe-composite_primary_keys-3.0.1 test/test_update.rb
composite_primary_keys-2.3.5.1 test/test_update.rb
composite_primary_keys-2.3.5 test/test_update.rb
composite_primary_keys-2.3.2 test/test_update.rb