From e40a294a65c9e58f19eeb619f29b06189bb6f7e2 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Tue, 31 Jul 2007 13:09:55 +0000 Subject: [PATCH] r249@sede: terceiro | 2007-07-29 19:24:09 -0300 ActionItem0: adding support for design inheritance --- vendor/plugins/design/README | 6 ++++++ vendor/plugins/design/init.rb | 2 +- vendor/plugins/design/test/design_test.rb | 5 ++++- vendor/plugins/design/test/test_helper.rb | 6 +++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/vendor/plugins/design/README b/vendor/plugins/design/README index 9ab9198..d46e102 100644 --- a/vendor/plugins/design/README +++ b/vendor/plugins/design/README @@ -48,6 +48,12 @@ The argument do +design_display_boxes()+ is the content you want to be the main content. Almost always you'll want to pass +yield+ (the resulting content for the current action) there, but you can pass anything you want. +== Controller subclassing and design + +Designs are inherited through the inheritance tree. This way you can for +example declare the use of a design in ApplicationController and let the other +controllers abstract that fact that they are using design. + == Storing design information in ActiveRecord models: +acts_as_design+ You can also use ActiveRecord objects diff --git a/vendor/plugins/design/init.rb b/vendor/plugins/design/init.rb index aba8d30..b54b9a4 100644 --- a/vendor/plugins/design/init.rb +++ b/vendor/plugins/design/init.rb @@ -16,7 +16,7 @@ class ActionController::Base @design_plugin_config = config def self.design_plugin_config - @design_plugin_config + @design_plugin_config || self.superclass.design_plugin_config end include Design diff --git a/vendor/plugins/design/test/design_test.rb b/vendor/plugins/design/test/design_test.rb index af50dfb..035c01e 100644 --- a/vendor/plugins/design/test/design_test.rb +++ b/vendor/plugins/design/test/design_test.rb @@ -52,8 +52,11 @@ class DesignTest < Test::Unit::TestCase def test_subclass_controller_can_override_superclass_design_holder assert_equal 'sample_object', ProxyDesignHolderTestController.send(:design_plugin_config)[:holder] - assert_equal 'another_object', InheritanceDesignTestController.send(:design_plugin_config)[:holder] + assert_equal 'another_object', InheritanceWithOverrideDesignTestController.send(:design_plugin_config)[:holder] + end + def test_subclass_should_inherit_supeclass_design + assert_equal 'sample_object', InheritanceDesignTestController.send(:design_plugin_config)[:holder] end end diff --git a/vendor/plugins/design/test/test_helper.rb b/vendor/plugins/design/test/test_helper.rb index ea44229..df069c3 100644 --- a/vendor/plugins/design/test/test_helper.rb +++ b/vendor/plugins/design/test/test_helper.rb @@ -60,10 +60,14 @@ class AnotherTestDesignHolder attr_accessor :template, :theme, :icon_theme, :boxes end -class InheritanceDesignTestController < ProxyDesignHolderTestController +class InheritanceWithOverrideDesignTestController < ProxyDesignHolderTestController design :holder => 'another_object' end +class InheritanceDesignTestController < ProxyDesignHolderTestController + # nothing +end + class DesignEditorTestController < ActionController::Base design_editor :holder => 'sample_object' def initialize -- libgit2 0.21.2