Browse files

Test for permalinks that escape to nothing printable (e.g. '////')

  • Loading branch information...
1 parent fd9710d commit 62e06d75334490503d6b3d6d06d51ebaf286b62a @martinemde martinemde committed Mar 12, 2009
Showing with 12 additions and 1 deletion.
  1. +4 −1 README
  2. +8 −0 test/permalink_fu_test.rb
@@ -22,16 +22,19 @@ These are set to nil if Iconv is not loaded. You can also manually set them to
Use the :if or :unless options to specify a Proc, method, or string to be called or evaluated. The permalink
will only be generated if the option evaluates to true.
[Added 3.11.2009 by Martin Emde] Make permalink_fu update your permalink everytime the dependent field(s) change.
class Article < ActiveRecord::Base
has_permalink :title, :update => true
+This will update your permalink every time title changes. Rails versions with _changed? methods will reduce the checks for uniqueness to only when the permalink field is changed.
Without :update set to true, your permalink will be set one time and subsequent changes to the field
(title in this example) will not affect the permalink field. To regenerate the permalink field,
set it to nil or a blank string within your model.
Old versions of rails without _changed? attribute support will result in the permalink field being regenerated every save.
-[Fixed 3.11.2009 by Martin Emde] Permalink was not being checked for uniqueness when set directly with permalink=
+[Bug Fixed 3.11.2009] Permalink was not being checked for uniqueness when set directly with permalink= on rails versions with _changed?
@@ -448,6 +448,14 @@ def test_should_assign_a_random_permalink_if_the_title_is_nil
assert @m.read_attribute(:permalink).size > 0
+ def test_should_assign_a_random_permalink_if_the_title_has_no_permalinkable_characters
+ @m =
+ @m.title = '////'
+ @m.validate
+ assert_not_nil @m.read_attribute(:permalink)
+ assert @m.read_attribute(:permalink).size > 0
+ end
def test_should_update_permalink_the_first_time_the_title_is_set
@m =
@m.title = "old title"

0 comments on commit 62e06d7

Please sign in to comment.