diff --git a/lib/has_scope.rb b/lib/has_scope.rb index 1f28f3a..76b3ddb 100644 --- a/lib/has_scope.rb +++ b/lib/has_scope.rb @@ -96,6 +96,7 @@ def has_scope(*scopes, &block) options[:only] = Array(options[:only]) options[:except] = Array(options[:except]) + options[:block] = block if block self.scopes_configuration = scopes_configuration.dup diff --git a/test/has_scope_test.rb b/test/has_scope_test.rb index c61abdc..3a79a5c 100644 --- a/test/has_scope_test.rb +++ b/test/has_scope_test.rb @@ -76,6 +76,9 @@ def default_render class BonsaisController < TreesController has_scope :categories, if: :categories? + has_scope :content do |controller, scope| + scope.by_content('some other content') + end protected def categories? @@ -483,6 +486,11 @@ def test_overwritten_scope assert_equal(:categories?, BonsaisController.scopes_configuration[:categories][:if]) end + def test_overwritten_scope_with_block + assert_nil(TreesController.scopes_configuration[:content][:block]) + assert(BonsaisController.scopes_configuration[:content][:block]) + end + protected def mock_tree(stubs = {})