aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorStefan Henzen <stefan.henzen@gmail.com>2014-10-09 15:45:49 +0200
committerStefan Henzen <stefan.henzen@gmail.com>2014-10-09 15:45:49 +0200
commite86cadc257caf6dcd762810f022e5d4009c6ca25 (patch)
tree199e9ba62481118e17a3f139155eaa4f470a6c22 /actionpack/test
parent344ec1b6a7ed102ce6a92c31e3b64364f4bdb772 (diff)
downloadrails-e86cadc257caf6dcd762810f022e5d4009c6ca25.tar.gz
rails-e86cadc257caf6dcd762810f022e5d4009c6ca25.tar.bz2
rails-e86cadc257caf6dcd762810f022e5d4009c6ca25.zip
Request#check_method no longer breaks when :en is not available locale
Request#check_method would use to_sentence(locale: :en), which breaks when I18n.available_locales does not include :en and I18n.enforce_available_locales is true (default). Inlined to_sentence functionality to solve this.
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/dispatch/request_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb
index a58306ea0a..940ebc0224 100644
--- a/actionpack/test/dispatch/request_test.rb
+++ b/actionpack/test/dispatch/request_test.rb
@@ -683,6 +683,22 @@ class RequestMethod < BaseRequestTest
end
end
+ test "exception on invalid HTTP method unaffected by I18n settings" do
+ old_locales = I18n.available_locales
+ old_enforce = I18n.config.enforce_available_locales
+
+ begin
+ I18n.available_locales = [:nl]
+ I18n.config.enforce_available_locales = true
+ assert_raise(ActionController::UnknownHttpMethod) do
+ stub_request('REQUEST_METHOD' => '_RANDOM_METHOD').method
+ end
+ ensure
+ I18n.available_locales = old_locales
+ I18n.config.enforce_available_locales = old_enforce
+ end
+ end
+
test "post masquerading as patch" do
request = stub_request(
'REQUEST_METHOD' => 'PATCH',