Permalink
Browse files

Merge branch '4.0-stable'

Conflicts:
	Changelog.md
	test/history_test.rb
  • Loading branch information...
2 parents ec66c2d + fc73536 commit b8d3a2b2bb3096d4a5a848e473c8dc86e14dc396 @norman committed Jan 21, 2013
Showing with 23 additions and 4 deletions.
  1. +4 −0 Changelog.md
  2. +4 −1 lib/friendly_id/slug.rb
  3. +15 −3 test/history_test.rb
View
4 Changelog.md
@@ -10,6 +10,10 @@ suggestions, ideas and improvements to FriendlyId.
Made the :scoped and :history modules compatible with each other (Andre Duffeck)
+## 4.0.10 (NOT RELEASED YET)
+
+* Fixed table prefixes/suffixes being ignored (Jesse Farless)
+
## 4.0.9 (2012-10-31)
* Fixed support for Rails 3.2.9.rc1
View
5 lib/friendly_id/slug.rb
@@ -3,9 +3,12 @@ module FriendlyId
#
# @see FriendlyId::History
class Slug < ActiveRecord::Base
- self.table_name = "friendly_id_slugs"
belongs_to :sluggable, :polymorphic => true
+ def self.name
+ "FriendlyIdSlug"
+ end
+
def to_param
slug
end
View
18 test/history_test.rb
@@ -121,6 +121,20 @@ def model_class
end
end
+ test 'should name table according to prefix and suffix' do
+ transaction do
+ begin
+ prefix = "prefix_"
+ without_prefix = FriendlyId::Slug.table_name
+ ActiveRecord::Base.table_name_prefix = prefix
+ FriendlyId::Slug.reset_table_name
+ assert_equal prefix + without_prefix, FriendlyId::Slug.table_name
+ ensure
+ ActiveRecord::Base.table_name_prefix = ""
+ FriendlyId::Slug.table_name = without_prefix
+ end
+ end
+ end
end
class HistoryTestWithSti < HistoryTest
@@ -137,8 +151,6 @@ def model_class
end
end
-
-
class City < ActiveRecord::Base
has_many :restaurants
end
@@ -199,4 +211,4 @@ def model_class
assert_equal record.slug, second_record.slug
end
-end
+end

0 comments on commit b8d3a2b

Please sign in to comment.