aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/abstract
diff options
context:
space:
mode:
authorPiotr Niełacny <piotr.nielacny@gmail.com>2013-05-16 15:37:19 +0200
committerLTe <piotr.nielacny@gmail.com>2013-07-10 11:26:43 +0200
commite0438b1c071d8dc2c7fc87075485d4ac01f4eb07 (patch)
tree1e32dee1c3d40652cca3734c0ddfe89defac045d /actionpack/test/abstract
parentcd0d5902dd237794049cac1ee89ab0c07a16a851 (diff)
downloadrails-e0438b1c071d8dc2c7fc87075485d4ac01f4eb07.tar.gz
rails-e0438b1c071d8dc2c7fc87075485d4ac01f4eb07.tar.bz2
rails-e0438b1c071d8dc2c7fc87075485d4ac01f4eb07.zip
Show real LoadError on helpers require
When helper try to require missing file rails will throw exception about missing helper. # app/helpers/my_helper.rb require 'missing' module MyHelper end And when we try do load helper class ApplicationController helper :my end Rails will throw exception. This is wrong because there is a helper file. Missing helper file helpers/my_helper.rb Now when helper try to require non-existed file rails will throw proper exception. No such file to load -- missing
Diffstat (limited to 'actionpack/test/abstract')
-rw-r--r--actionpack/test/abstract/.helper_test.rb.swpbin0 -> 12288 bytes
-rw-r--r--actionpack/test/abstract/helper_test.rb20
2 files changed, 20 insertions, 0 deletions
diff --git a/actionpack/test/abstract/.helper_test.rb.swp b/actionpack/test/abstract/.helper_test.rb.swp
new file mode 100644
index 0000000000..d029f89288
--- /dev/null
+++ b/actionpack/test/abstract/.helper_test.rb.swp
Binary files differ
diff --git a/actionpack/test/abstract/helper_test.rb b/actionpack/test/abstract/helper_test.rb
index 7960e5b55b..2cc27fbecd 100644
--- a/actionpack/test/abstract/helper_test.rb
+++ b/actionpack/test/abstract/helper_test.rb
@@ -48,6 +48,14 @@ module AbstractController
end
end
+ class AbstractInvalidHelpers < AbstractHelpers
+ include ActionController::Helpers
+
+ path = File.join(File.expand_path('../../fixtures', __FILE__), "helpers_missing")
+ $:.unshift(path)
+ self.helpers_path = path
+ end
+
class TestHelpers < ActiveSupport::TestCase
def setup
@controller = AbstractHelpers.new
@@ -97,5 +105,17 @@ module AbstractController
assert_equal "Hello Default", @controller.response_body
end
end
+
+ class InvalidHelpersTest < ActiveSupport::TestCase
+ def test_controller_raise_error_about_real_require_problem
+ e = assert_raise(LoadError) { AbstractInvalidHelpers.helper(:invalid_require) }
+ assert_equal "No such file to load -- very_invalid_file_name", e.message
+ end
+
+ def test_controller_raise_error_about_missing_helper
+ e = assert_raise(Helpers::ClassMethods::MissingHelperError) { AbstractInvalidHelpers.helper(:missing) }
+ assert_equal "Missing helper file helpers/missing_helper.rb", e.message
+ end
+ end
end
end