Sha256: 6535351de006b1ca0db9241fd6733859b8ea5d73b4a262a24761b3af9d6ae8ef

Contents?: true

Size: 753 Bytes

Versions: 2

Compression:

Stored size: 753 Bytes

Contents

require 'test_helper'

class RecordsTest < ActiveSupport::TestCase

  test 'save' do
    user = User.create(first_name: 'Zakk', last_name: 'Wylde')
    assert_equal 'zakk-wylde', user.slug

    user.update slug: 'yngwie-malmsteen'
    assert_equal 'yngwie-malmsteen', user.slug
  end

  test 'uniqueness' do
    2.times { Shop.create(name: 'Guitar Shop') }
    shop = Shop.last
    assert_equal "guitar-shop-#{shop.id}", shop.slug

    2.times { Category.create(name: 'Gibson', shop: shop) }
    category = Category.last
    assert_equal "gibson-#{category.id}", category.slug

    2.times { Product.create(name: 'Les Paul', shop: shop, category: category) }
    product = Product.last
    assert_equal "les-paul-#{product.id}", product.slug
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slugs-2.0.1 test/records_test.rb
slugs-2.0.0 test/records_test.rb