Sha256: efdd0cf05c0c320fdc6037b25ec505c1f56868f689976865944d6858bb0fc9c6
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require File.expand_path("../helper.rb", __FILE__) class Manual < ActiveRecord::Base include FriendlyId::History has_friendly_id :name end class HistoryTest < MiniTest::Unit::TestCase include FriendlyId::Test include FriendlyId::Test::Shared def klass Manual end test "should insert record in slugs table on create" do with_instance_of(klass) {|record| assert !record.friendly_id_slugs.empty?} end test "should not create new slug record if friendly_id is not changed" do with_instance_of(klass) do |record| record.active = true record.save! assert_equal 1, FriendlyIdSlug.count end end test "should create new slug record when friendly_id changes" do with_instance_of(klass) do |record| record.name = record.name + "b" record.save! assert_equal 2, FriendlyIdSlug.count end end test "should be findable by old slugs" do with_instance_of(klass) do |record| old_friendly_id = record.friendly_id record.name = record.name + "b" record.save! assert found = klass.find_by_friendly_id(old_friendly_id) assert !found.readonly? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
friendly_id4-4.0.0.beta1 | test/history_test.rb |