Sha256: 1c59b0f1cb5dd01bd0ebd69acfb0b05c387091bcc5c3a21145be3f406af2d0df

Contents?: true

Size: 915 Bytes

Versions: 11

Compression:

Stored size: 915 Bytes

Contents

require 'abstract_unit'

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

11 entries across 11 versions & 1 rubygems

Version Path
composite_primary_keys-3.1.11 test/test_update.rb
composite_primary_keys-3.1.10 test/test_update.rb
composite_primary_keys-3.1.9 test/test_update.rb
composite_primary_keys-3.1.8 test/test_update.rb
composite_primary_keys-3.1.7 test/test_update.rb
composite_primary_keys-3.1.6 test/test_update.rb
composite_primary_keys-3.1.5 test/test_update.rb
composite_primary_keys-3.1.4 test/test_update.rb
composite_primary_keys-3.1.2 test/test_update.rb
composite_primary_keys-3.1.1 test/test_update.rb
composite_primary_keys-3.1.0 test/test_update.rb