Add decorates_associations to decorate multiple associations
This commit is contained in:
parent
1580baa287
commit
d10365551c
|
@ -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.
|
||||
#
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue