2008-09-09 17:19:07 -04:00
|
|
|
require 'abstract_unit'
|
|
|
|
|
|
|
|
# class TranslatingController < ActionController::Base
|
|
|
|
# end
|
|
|
|
|
2012-01-05 20:01:45 -05:00
|
|
|
class TranslationControllerTest < ActiveSupport::TestCase
|
2008-09-09 17:19:07 -04:00
|
|
|
def setup
|
|
|
|
@controller = ActionController::Base.new
|
|
|
|
end
|
2010-08-14 01:13:00 -04:00
|
|
|
|
2008-09-09 17:19:07 -04:00
|
|
|
def test_action_controller_base_responds_to_translate
|
2010-05-17 14:40:56 -04:00
|
|
|
assert_respond_to @controller, :translate
|
2008-09-09 17:19:07 -04:00
|
|
|
end
|
2010-08-14 01:13:00 -04:00
|
|
|
|
2008-09-09 17:19:07 -04:00
|
|
|
def test_action_controller_base_responds_to_t
|
2010-05-17 14:40:56 -04:00
|
|
|
assert_respond_to @controller, :t
|
2008-09-09 17:19:07 -04:00
|
|
|
end
|
2010-08-14 01:13:00 -04:00
|
|
|
|
2008-09-09 17:19:07 -04:00
|
|
|
def test_action_controller_base_responds_to_localize
|
2010-05-17 14:40:56 -04:00
|
|
|
assert_respond_to @controller, :localize
|
2008-09-09 17:19:07 -04:00
|
|
|
end
|
2010-08-14 01:13:00 -04:00
|
|
|
|
2008-09-09 17:19:07 -04:00
|
|
|
def test_action_controller_base_responds_to_l
|
2010-05-17 14:40:56 -04:00
|
|
|
assert_respond_to @controller, :l
|
2008-09-09 17:19:07 -04:00
|
|
|
end
|
2012-07-18 03:33:14 -04:00
|
|
|
|
|
|
|
def test_lazy_lookup
|
|
|
|
expected = 'bar'
|
|
|
|
@controller.stubs(:action_name => :index)
|
|
|
|
I18n.stubs(:translate).with('action_controller.base.index.foo').returns(expected)
|
|
|
|
assert_equal expected, @controller.t('.foo')
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_default_translation
|
|
|
|
key, expected = 'one.two' 'bar'
|
|
|
|
I18n.stubs(:translate).with(key).returns(expected)
|
|
|
|
assert_equal expected, @controller.t(key)
|
|
|
|
end
|
2012-01-05 20:01:45 -05:00
|
|
|
end
|