Permalink
Browse files

scope_key_by_partial fix for Ruby 1.9 when there's virtual_path [#4202

…state:resolved]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
spastorino authored and jeremy committed Mar 16, 2010
1 parent 7a5da21 commit 0c1ac36ccb7d72f3d17d950d030442a7e83d0708
@@ -29,9 +29,10 @@ def localize(*args)
private
def scope_key_by_partial(key)
- if (key.respond_to?(:join) ? key.join : key.to_s).first == "."
+ strkey = key.respond_to?(:join) ? key.join : key.to_s
+ if strkey.first == "."
if @_virtual_path
- @_virtual_path.gsub(%r{/_?}, ".") + key.to_s
+ @_virtual_path.gsub(%r{/_?}, ".") + strkey
else
raise "Cannot use t(#{key.inspect}) shortcut because path is not available"
end
@@ -0,0 +1 @@
+<%= t(['.foo', '.bar']) %>
@@ -41,4 +41,10 @@ def test_scoping_by_partial
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
assert_equal "helper", @view.render(:file => "test/translation")
end
+
+ def test_scoping_by_partial_of_an_array
+ I18n.expects(:translate).with("test.scoped_array_translation.foo.bar", :raise => true).returns(["foo", "bar"])
+ @view = ActionView::Base.new(ActionController::Base.view_paths, {})
+ assert_equal "foobar", @view.render(:file => "test/scoped_array_translation")
+ end
end

0 comments on commit 0c1ac36

Please sign in to comment.