Add decorates_associations to decorate multiple associations

This commit is contained in:
Michael Fairley 2011-11-19 15:02:04 -08:00
parent 1580baa287
commit d10365551c
2 changed files with 18 additions and 0 deletions

View File

@ -69,6 +69,14 @@ module Draper
end
end
# A convenience method for decorating multiple associations. Calls
# decorates_association on each of the given symbols.
#
# @param [Symbols*] name of associations to decorate
def self.decorates_associations(*association_symbols)
association_symbols.each{ |sym| decorates_association(sym) }
end
# Specifies a black list of methods which may *not* be proxied to
# to the wrapped object.
#

View File

@ -95,6 +95,16 @@ describe Draper::Base do
end
end
context('.decorates_associations') do
subject { Decorator }
it "decorates each of the associations" do
subject.should_receive(:decorates_association).with(:similar_products)
subject.should_receive(:decorates_association).with(:previous_version)
subject.decorates_associations :similar_products, :previous_version
end
end
context(".model / .to_model") do
it "should return the wrapped object" do
subject.to_model.should == source