Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11529: test_validate_uniqueness_with_columns_which_are_sql_keywords.diff

File test_validate_uniqueness_with_columns_which_are_sql_keywords.diff, 1.4 kB (added by maccman, 6 months ago)
  • test/schema/schema.rb

    old new  
    202202      t.integer  :parent_id 
    203203      t.string   :type 
    204204    end 
     205     
     206    create_table :guids, :force => true do |t| 
     207      t.string :key 
     208    end 
    205209 
    206210 
    207211 
  • test/models/guid.rb

    old new  
     1class Guid < ActiveRecord::Base 
     2end 
  • test/cases/validations_test.rb

    old new  
    55require 'models/person' 
    66require 'models/developer' 
    77require 'models/warehouse_thing' 
     8require 'models/guid' 
    89 
    910# The following methods in Topic are used in test_conditional_validation_* 
    1011class Topic 
     
    459460    assert !t3.errors.on(:parent_id) 
    460461    assert_not_equal "has already been taken", t3.errors.on(:title) 
    461462  end 
     463   
     464  def test_validate_uniqueness_with_columns_which_are_sql_keywords 
     465    Guid.validates_uniqueness_of :key 
     466    g = Guid.new 
     467    g.key = "foo" 
     468    assert_nothing_raised { !g.valid? } 
     469  end 
    462470 
    463471  def test_validate_uniqueness_with_non_standard_table_names 
    464472    i1 = WarehouseThing.create(:value => 1000)