Skip to content

Commit

Permalink
Fix rescue from LoadError in engine loading
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegSmelov committed Oct 17, 2016
1 parent 4434f0a commit db80339
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/inherited_resources/class_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def initialize_resources_class_accessors! #:nodoc:
namespaces.delete_if do |namespace|
begin
"#{namespace}/engine".camelize.constantize.isolated?
rescue
rescue StandardError, LoadError
false
end
end
Expand Down
3 changes: 3 additions & 0 deletions test/autoload/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module MyTestNamespace
class Engine; end
end
12 changes: 12 additions & 0 deletions test/class_methods_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ module MyNamespace
class PeopleController < InheritedResources::Base; end
end

module EmptyNamespace; end

class ActionsClassMethodTest < ActionController::TestCase
tests BooksController

Expand Down Expand Up @@ -206,3 +208,13 @@ def test_route_prefix_present_when_parent_module_is_not_a_engine
assert_equal 'my_namespace', MyNamespace::PeopleController.send(:resources_configuration)[:self][:route_prefix]
end
end

class EngineLoadErrorTest < ActiveSupport::TestCase
def test_does_not_crash_on_engine_load_error
ActiveSupport::Dependencies.autoload_paths << 'test/autoload'

EmptyNamespace.class_eval <<-RUBY
class PeopleController < InheritedResources::Base; end
RUBY
end
end

0 comments on commit db80339

Please sign in to comment.