Guest User

Untitled

a guest
Mar 5th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. # product_test.rb
  2.  
  3. require 'test_helper'
  4.  
  5. class ProductTest < ActiveSupport::TestCase
  6. test "uniqueness of description" do
  7. @product1 = Product.new(:description => "teste áéíóú")
  8. @product2 = Product.new(:description => "teste áéíóú")
  9.  
  10. assert @product1.save
  11. assert !@product2.valid?
  12.  
  13. assert_match /has already been taken/, @product2.errors.on(:description)
  14. end
  15. end
  16.  
  17. # product.rb
  18.  
  19. class Product < ActiveRecord::Base
  20. validates_uniqueness_of :description
  21. end
  22.  
  23. # database.yml
  24.  
  25. test:
  26. adapter: mysql
  27. encoding: utf8
  28. database: blog_test
  29. username: root
  30. password:
Add Comment
Please, Sign In to add comment