Sha256: edb89452b08f74036a5e17bfb4ad599731a8af1cf56beba3894df176285471fd

Contents?: true

Size: 711 Bytes

Versions: 7

Compression:

Stored size: 711 Bytes

Contents

require File.expand_path('../abstract_unit', __FILE__)

class EmployeesGroup < ActiveRecord::Base
  
end

class TestValidations < ActiveSupport::TestCase
  fixtures :employees

  def test_delete_for_model_without_primary_key
    EmployeesGroup.create(employee_id: 1, group_id: 100)
    EmployeesGroup.create(employee_id: 2, group_id: 102)
    EmployeesGroup.create(employee_id: 3, group_id: 103)

    assert_equal(EmployeesGroup.all.size, 3)
    exception = assert_raises(ActiveRecord::StatementInvalid) {
      EmployeesGroup.where(employee_id: 1).first.destroy
    }
    assert_match(/Unknown column 'employees_groups.' in 'where clause/, exception.message)
    assert(EmployeesGroup.all.size == 3)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
composite_primary_keys-7.0.11 test/test_delete_all.rb
composite_primary_keys-7.0.10 test/test_delete_all.rb
composite_primary_keys-7.0.9 test/test_delete_all.rb
composite_primary_keys-7.0.8 test/test_delete_all.rb
composite_primary_keys-7.0.7 test/test_delete_all.rb
composite_primary_keys-7.0.6 test/test_delete_all.rb
composite_primary_keys-7.0.5 test/test_delete_all.rb