From 6e26be69606c52dbccfad366661b455157c35be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 20 Jan 2010 14:41:23 +0100 Subject: Move ActionController::Translation to AbstractController::Translation. --- actionpack/lib/abstract_controller.rb | 1 + actionpack/lib/abstract_controller/rendering.rb | 2 +- actionpack/lib/abstract_controller/translation.rb | 13 ++++++++++++ actionpack/lib/action_controller.rb | 1 - actionpack/lib/action_controller/base.rb | 2 +- actionpack/lib/action_controller/translation.rb | 13 ------------ actionpack/test/abstract/translation_test.rb | 26 +++++++++++++++++++++++ actionpack/test/controller/translation_test.rb | 26 ----------------------- 8 files changed, 42 insertions(+), 42 deletions(-) create mode 100644 actionpack/lib/abstract_controller/translation.rb delete mode 100644 actionpack/lib/action_controller/translation.rb create mode 100644 actionpack/test/abstract/translation_test.rb delete mode 100644 actionpack/test/controller/translation_test.rb (limited to 'actionpack') diff --git a/actionpack/lib/abstract_controller.rb b/actionpack/lib/abstract_controller.rb index efc35a7e56..725d8fb8fc 100644 --- a/actionpack/lib/abstract_controller.rb +++ b/actionpack/lib/abstract_controller.rb @@ -15,5 +15,6 @@ module AbstractController autoload :LocalizedCache autoload :Logger autoload :Rendering + autoload :Translation autoload :UrlFor end diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 644419a585..826e82c8c6 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -42,7 +42,7 @@ module AbstractController # Delegates render_to_body and sticks the result in self.response_body. def render(*args, &block) if response_body - raise AbstractController::DoubleRenderError, "Can only render or redirect once per action" + raise AbstractController::DoubleRenderError end options = _normalize_options(*args, &block) diff --git a/actionpack/lib/abstract_controller/translation.rb b/actionpack/lib/abstract_controller/translation.rb new file mode 100644 index 0000000000..6d68cf4944 --- /dev/null +++ b/actionpack/lib/abstract_controller/translation.rb @@ -0,0 +1,13 @@ +module AbstractController + module Translation + def translate(*args) + I18n.translate(*args) + end + alias :t :translate + + def localize(*args) + I18n.localize(*args) + end + alias :l :localize + end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb index 8bc2cc79d2..fa4a253ec1 100644 --- a/actionpack/lib/action_controller.rb +++ b/actionpack/lib/action_controller.rb @@ -8,7 +8,6 @@ module ActionController autoload :Base autoload :Caching autoload :PolymorphicRoutes - autoload :Translation autoload :Metal autoload :Middleware diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 4f928e37ea..21a811c004 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -4,6 +4,7 @@ module ActionController include AbstractController::Callbacks include AbstractController::Layouts + include AbstractController::Translation include ActionController::Helpers helper :all # By default, all helpers should be included @@ -33,7 +34,6 @@ module ActionController include ActionController::Streaming include ActionController::HttpAuthentication::Basic::ControllerMethods include ActionController::HttpAuthentication::Digest::ControllerMethods - include ActionController::Translation # Add instrumentations hooks at the bottom, to ensure they instrument # all the methods properly. diff --git a/actionpack/lib/action_controller/translation.rb b/actionpack/lib/action_controller/translation.rb deleted file mode 100644 index 65e9eddb0a..0000000000 --- a/actionpack/lib/action_controller/translation.rb +++ /dev/null @@ -1,13 +0,0 @@ -module ActionController - module Translation - def translate(*args) - I18n.translate(*args) - end - alias :t :translate - - def localize(*args) - I18n.localize(*args) - end - alias :l :localize - end -end \ No newline at end of file diff --git a/actionpack/test/abstract/translation_test.rb b/actionpack/test/abstract/translation_test.rb new file mode 100644 index 0000000000..0bf61a6556 --- /dev/null +++ b/actionpack/test/abstract/translation_test.rb @@ -0,0 +1,26 @@ +require 'abstract_unit' + +# class TranslatingController < ActionController::Base +# end + +class TranslationControllerTest < Test::Unit::TestCase + def setup + @controller = ActionController::Base.new + end + + def test_action_controller_base_responds_to_translate + assert @controller.respond_to?(:translate) + end + + def test_action_controller_base_responds_to_t + assert @controller.respond_to?(:t) + end + + def test_action_controller_base_responds_to_localize + assert @controller.respond_to?(:localize) + end + + def test_action_controller_base_responds_to_l + assert @controller.respond_to?(:l) + end +end \ No newline at end of file diff --git a/actionpack/test/controller/translation_test.rb b/actionpack/test/controller/translation_test.rb deleted file mode 100644 index 0bf61a6556..0000000000 --- a/actionpack/test/controller/translation_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'abstract_unit' - -# class TranslatingController < ActionController::Base -# end - -class TranslationControllerTest < Test::Unit::TestCase - def setup - @controller = ActionController::Base.new - end - - def test_action_controller_base_responds_to_translate - assert @controller.respond_to?(:translate) - end - - def test_action_controller_base_responds_to_t - assert @controller.respond_to?(:t) - end - - def test_action_controller_base_responds_to_localize - assert @controller.respond_to?(:localize) - end - - def test_action_controller_base_responds_to_l - assert @controller.respond_to?(:l) - end -end \ No newline at end of file -- cgit v1.2.3