diff --git a/CHANGELOG b/CHANGELOG
index ce590c8e..4885596e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,9 +2,9 @@
* Experimental comment preview. [court3nay]
-* Add multi-site admin interface [Vincent, j2m]
+* Add multi-site admin interface. [Vincent, j2m]
-* Update Wordpress converter to support Wordpress 2.3+ [Aubrey]
+* Update Wordpress converter to support Wordpress 2.3+. [Aubrey]
* refactor so that admin/comments is more restful, allow inline comment editing in the admin. [court3nay]
@@ -23,23 +23,23 @@
# use this order: :text, :title, :id, :class, :rel
link_to_article article, "click here", "this article", "article-1", "articles", "whatever-rel-means"
-* encode search/tag urls properly [rob-twf]
+* encode search/tag urls properly. [rob-twf]
* update article forms to explain new tag syntax (comma and space delimited tags) [xavier, rick]
-* start converting tests to rspec
+* start converting tests to rspec.
* tweak mephisto_init to support the new ActionController::Dispatcher class. [Rob Anderton]
* Don't generate an article event for unversioned changes. [Marcus Brito]
-* Switch to will_paginate plugin [Mislav]
+* Switch to will_paginate plugin. [Mislav]
-* unit test fixes for those not using mysql or psql [Mislav]
+* unit test fixes for those not using mysql or psql. [Mislav]
-* add comment moderation links to the overview [court3nay]
+* add comment moderation links to the overview. [court3nay]
-* convert tests to use test/spec instead of simply bdd [Chris McGrath]
+* convert tests to use test/spec instead of simply bdd. [Chris McGrath]
* move xmlrpc stuff to plugin. rails doesn't include AWS anymore. May need some simple autodetection so the plugin just prints a warning if AWS isn't found.
@@ -49,7 +49,7 @@
* Fix controllers so include_into works with them.
-* Change plugin class/module to Mephisto::Plugin and Mephisto::Plugins. Sorry for the breakage (still technically experimental!)
+* Change plugin class/module to Mephisto::Plugin and Mephisto::Plugins. Sorry for the breakage (still technically experimental!).
* Fix admin overview date timezone. [Ben Wyrosdick]
diff --git a/app/views/admin/articles/_page_nav.rhtml b/app/views/admin/articles/_page_nav.rhtml
index 8eb5b1e4..e6e34c08 100644
--- a/app/views/admin/articles/_page_nav.rhtml
+++ b/app/views/admin/articles/_page_nav.rhtml
@@ -38,7 +38,7 @@
-<% end unless @article.new_record? && @article.comments.empty? -%>
\ No newline at end of file
+<% end unless @article && @article.new_record? && @article.comments.size == 0 -%>
\ No newline at end of file
diff --git a/vendor/plugins/aaa/init.rb b/vendor/plugins/aaa/init.rb
index a50e38c3..0743048a 100644
--- a/vendor/plugins/aaa/init.rb
+++ b/vendor/plugins/aaa/init.rb
@@ -3,7 +3,7 @@
Module.class_eval do
# A hash that maps Class names to an array of Modules to mix in when the class is instantiated.
- @@class_mixins = {}
+ @@class_mixins = {} unless defined?(@@class_mixins)
mattr_reader :class_mixins
# Specifies that this module should be included into the given classes when they are instantiated.
@@ -11,18 +11,46 @@
# module FooMethods
# include_into "Foo", "Bar"
# end
+ #
+ # You can also specify a hash to have your module's methods alias_method_chained to the target
+ # class' methods.
+ #
+ # module FooMethods
+ # include_into "Foo", :method => :feature
+ # end
+ #
+ # This will alias Foo#method to the newly included FooMethods#method_with_feature. The former
+ # method Foo#method will continue to be available as Foo#method_without_feature.
+ #
def include_into(*klasses)
klasses.flatten!
+ aliases = klasses.last.is_a?(Hash) ? klasses.pop : {}
klasses.each do |klass|
- (@@class_mixins[klass] ||= []) << name.to_s
+ (@@class_mixins[klass] ||= []) << [name.to_s, aliases]
@@class_mixins[klass].uniq!
end
end
-
+
# add any class mixins that have been registered for this class
def auto_include!
- mixins = @@class_mixins[name]
- send(:include, *mixins.collect { |name| name.constantize }) if mixins
+ if mixins = @@class_mixins[name]
+ mixins.each do |name, aliases|
+ include name.constantize
+ aliases.each { |args| alias_chain *args }
+ end
+ end
+ end
+
+ def alias_chain(target, feature)
+ (class << self; self end).class_eval <<-EOC, __FILE__, __LINE__
+ def method_added_with_#{target}_#{feature}(method)
+ if method == :#{target} && !method_defined?(:#{target}_without_#{feature})
+ alias_method_chain :#{target}, :#{feature}
+ end
+ method_added_without_#{target}_#{feature}(method)
+ end
+ alias_method_chain :method_added, :#{target}_#{feature}
+ EOC
end
end
diff --git a/vendor/plugins/aaa/test/include_into_test.rb b/vendor/plugins/aaa/test/include_into_test.rb
new file mode 100644
index 00000000..ee82fdf5
--- /dev/null
+++ b/vendor/plugins/aaa/test/include_into_test.rb
@@ -0,0 +1,45 @@
+ENV['RAILS_ENV'] = 'test'
+RAILS_ROOT = File.join(File.dirname(__FILE__), '../../../../')
+
+require 'rubygems'
+require 'active_support'
+require 'test/unit'
+
+require File.join(File.dirname(__FILE__), '..', 'init.rb')
+
+module Chocolate
+ include_into 'Cookie', 'Coffee', :taste => :chocolate
+ def taste_with_chocolate; "#{self.class.name} with chocolate!" end
+end
+
+module Latte
+ include_into 'Coffee', 'Chai'
+end
+
+class Cookie
+ def taste; "just a #{self.class.name}" end
+end
+
+class Coffee
+ def taste; "just a #{self.class.name}" end
+end
+
+class Chai
+end
+
+class IncludeIntoTest < Test::Unit::TestCase
+ def test_module_should_be_included_to_given_classes
+ assert Cookie.included_modules.include?(Chocolate)
+ assert Coffee.included_modules.include?(Chocolate)
+ end
+
+ def test_methods_should_be_alias_chained_in_given_classes
+ assert_equal 'Cookie with chocolate!', Cookie.new.taste
+ assert_equal 'Coffee with chocolate!', Coffee.new.taste
+ end
+
+ def test_should_work_without_alias_option
+ assert Coffee.included_modules.include?(Latte)
+ assert Chai.included_modules.include?(Latte)
+ end
+end
\ No newline at end of file