diff --git a/lib/yuba/view_model/rendering.rb b/lib/yuba/view_model/rendering.rb index 8206478..4aa4fab 100644 --- a/lib/yuba/view_model/rendering.rb +++ b/lib/yuba/view_model/rendering.rb @@ -19,8 +19,6 @@ def _protected_ivars def view_model_assigns return {} unless defined?(@_view_model) - # TODO: get all public methods between self and Yuba::ViewModel - # now get only in self methods = @_view_model.public_methods(false) methods.reject! do |method_name| %i[initialize].include?(method_name) || diff --git a/test/yuba/view_model/rendering_test.rb b/test/yuba/view_model/rendering_test.rb index d04ff03..34dad4d 100644 --- a/test/yuba/view_model/rendering_test.rb +++ b/test/yuba/view_model/rendering_test.rb @@ -23,6 +23,10 @@ def _protected_ivars property :name, public: true end + inherited_view_model_class = Class.new(simple_view_model_class) do + property :email, public: true + end + view_model_class_with_predicate_method = Class.new(Yuba::ViewModel) do property :name, public: true @@ -44,4 +48,11 @@ def enable? action_controller.render(view_model: view_model) assert_equal({ name: 'willnet' }, action_controller.view_assigns) end + + test 'subclass of subclass of Yuba::ViewModel works' do + action_controller = action_controller_class.new + view_model = inherited_view_model_class.new(name: 'willnet', email: 'test@example.com') + action_controller.render(view_model: view_model) + assert_equal({ name: 'willnet', email: 'test@example.com' }, action_controller.view_assigns) + end end