public
Description: Pretty url support for Ruby on Rails applications
Homepage: http://www.caring.com
Clone URL: git://github.com/caring/acts_as_url_param.git
Don't set url_nasme to be blank if one alreafy exists. Fixes #759
joshuabates (author)
Mon Jan 28 14:26:57 -0800 2008
commit  ec4c03f3e81b19e513e01306cc77f128350dce58
tree    89d507e7761e493965883261ea35a5920a5e9852
parent  24d19760a9b1f542be2b7919760b97ab69b17d65
...
115
116
117
118
 
 
119
120
121
...
115
116
117
 
118
119
120
121
122
0
@@ -115,7 +115,8 @@ module ActsAsUrlParam
0
       
0
       def set_url_param
0
         if url_param.blank? or acts_as_url_options[:on] != :create
0
- write_attribute(acts_as_url_options[:column], compute_url_param)
0
+ url = compute_url_param
0
+ write_attribute(acts_as_url_options[:column], url) unless url.blank?
0
         end
0
         @url_param_validated = true
0
       end
...
87
88
89
 
 
 
 
 
 
 
90
91
92
...
87
88
89
90
91
92
93
94
95
96
97
98
99
0
@@ -87,6 +87,13 @@ class ActsAsUrlParamTest < Test::Unit::TestCase
0
     author.update_attributes(:bio => 'unrelated to url param')
0
     assert_equal(author_url, author.to_param)
0
   end
0
+
0
+ def test_should_not_set_existing_url_name_to_blank
0
+ author = ActsAsUrlParam::Author.create(:label => 'name of author')
0
+ author_url = author.to_param
0
+ author.update_attributes(:label => '')
0
+ assert_equal(author_url, author.to_param)
0
+ end
0
 
0
   def test_should_not_update_url_name_by_default
0
     item = ActsAsUrlParam::Item.create(:name => 'this is a url param')
...
1
2
 
3
4
...
1
 
2
3
4
0
@@ -1,3 +1,3 @@
0
 class ActsAsUrlParam::Author < ActsAsUrlParamBase
0
- acts_as_url_param :on => :update
0
+ acts_as_url_param :on => :update, :allow_blank => true
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.