Sha256: 22ba4aa2b307556795f29baf8afca13e074a7582a5b9d71143cd3bf1cac894b5

Contents?: true

Size: 621 Bytes

Versions: 6

Compression:

Stored size: 621 Bytes

Contents

require_relative "../lib/ohm/slug"
require_relative "helper"

class Article < Ohm::Model
  include Ohm::Slug

  attribute :title

  def to_s
    title
  end
end

test "to_param" do
  article = Article.create(title: "A very Unique and Interesting String?'")

  assert_equal '1-a-very-unique-and-interesting-string', article.to_param
end

test "finding" do
  article = Article.create(title: "A very Unique and Interesting String?'")

  assert_equal 1, Article[article.to_param].id
end

test "transliterate non-ascii characters" do
  article = Article.create(title: "Décor")

  assert_equal article.to_param, "1-decor"
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ohm-contrib-3.0.0 test/slug.rb
ohm-contrib-2.2.0 test/slug.rb
ohm-contrib-2.0.1 test/slug.rb
ohm-contrib-2.0.0 test/slug.rb
ohm-contrib-2.0.0.rc2 test/slug.rb
ohm-contrib-2.0.0.rc1 test/slug.rb