Created
September 29, 2008 23:26
-
-
Save lifo/13712 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/vendor/plugins/stringex/lib/lucky_sneaks/acts_as_url.rb b/vendor/plugins/stringex/lib/lucky_sneaks/acts_as_url.rb | |
index 156f45f..77a3ae0 100644 | |
--- a/vendor/plugins/stringex/lib/lucky_sneaks/acts_as_url.rb | |
+++ b/vendor/plugins/stringex/lib/lucky_sneaks/acts_as_url.rb | |
@@ -43,7 +43,7 @@ module LuckySneaks | |
# on a large selection, you will get much better results writing your own version with | |
# using pagination. | |
def initialize_urls | |
- find(:all, :conditions => {:url => nil}).each do |instance| | |
+ find(:all, :conditions => {self.url_attribute => nil}).each do |instance| | |
instance.send :ensure_unique_url | |
instance.save | |
end | |
diff --git a/vendor/plugins/stringex/test/acts_as_url_test.rb b/vendor/plugins/stringex/test/acts_as_url_test.rb | |
index bb0fa92..0b94fa8 100644 | |
--- a/vendor/plugins/stringex/test/acts_as_url_test.rb | |
+++ b/vendor/plugins/stringex/test/acts_as_url_test.rb | |
@@ -106,4 +106,19 @@ class ActsAsUrlTest < Test::Unit::TestCase | |
assert_equal "initial", @doc_1.url | |
assert_equal "subsequent", @doc_2.url | |
end | |
+ | |
+ def test_should_mass_initialize_urls_with_custom_url_attribute | |
+ @doc_1 = Permument.create!(:title => "Initial") | |
+ @doc_2 = Permument.create!(:title => "Subsequent") | |
+ @doc_1.update_attribute :permalink, nil | |
+ @doc_2.update_attribute :permalink, nil | |
+ assert_nil @doc_1.permalink | |
+ assert_nil @doc_2.permalink | |
+ Permument.initialize_urls | |
+ @doc_1.reload | |
+ @doc_2.reload | |
+ assert_equal "initial", @doc_1.permalink | |
+ assert_equal "subsequent", @doc_2.permalink | |
+ end | |
+ | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment