Skip to content

Commit 62e06d7

Browse files
committed
Test for permalinks that escape to nothing printable (e.g. '////')
1 parent fd9710d commit 62e06d7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,19 @@ These are set to nil if Iconv is not loaded. You can also manually set them to
2222
Use the :if or :unless options to specify a Proc, method, or string to be called or evaluated. The permalink
2323
will only be generated if the option evaluates to true.
2424

25+
2526
[Added 3.11.2009 by Martin Emde] Make permalink_fu update your permalink everytime the dependent field(s) change.
2627

2728
class Article < ActiveRecord::Base
2829
has_permalink :title, :update => true
2930
end
3031

32+
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.
33+
3134
Without :update set to true, your permalink will be set one time and subsequent changes to the field
3235
(title in this example) will not affect the permalink field. To regenerate the permalink field,
3336
set it to nil or a blank string within your model.
3437

3538
Old versions of rails without _changed? attribute support will result in the permalink field being regenerated every save.
3639

37-
[Fixed 3.11.2009 by Martin Emde] Permalink was not being checked for uniqueness when set directly with permalink=
40+
[Bug Fixed 3.11.2009] Permalink was not being checked for uniqueness when set directly with permalink= on rails versions with _changed?

test/permalink_fu_test.rb

+8
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,14 @@ def test_should_assign_a_random_permalink_if_the_title_is_nil
448448
assert @m.read_attribute(:permalink).size > 0
449449
end
450450

451+
def test_should_assign_a_random_permalink_if_the_title_has_no_permalinkable_characters
452+
@m = NoChangeModel.new
453+
@m.title = '////'
454+
@m.validate
455+
assert_not_nil @m.read_attribute(:permalink)
456+
assert @m.read_attribute(:permalink).size > 0
457+
end
458+
451459
def test_should_update_permalink_the_first_time_the_title_is_set
452460
@m = ChangedWithoutUpdateModel.new
453461
@m.title = "old title"

0 commit comments

Comments
 (0)