Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActionView::Template doesn't support multipart formats with locale

#2284

ActionView::Template seems to parse templates with multipart format and locale incorrectly. That is if you have a file template.en.text.plain.erb it falls back to thinking 'en' is the format.

Here's how it parses a simple template:


#<ActionView::ReloadableTemplate:0x3b84194 @previously_last_modified=Tue Mar 17 12:33:25 +0100 2009, @_memoized_method_segment=["app47views47mailer47activation46en46text46plain46erb"], @format="en", @_memoized_relative_path=["app/views/mailer/activation.en.text.plain.erb"], @extension=nil, @_memoized_method_name_without_locals=["_run_app47views47mailer47activation46en46text46plain46erb"], @load_path="/Users/matid/Projects/***/trunk/app/views", @base_path="mailer", @filename="/Users/matid/Projects/***/trunk/app/views/mailer/activation.en.text.plain.erb", @locale=nil, @name="activation", @template_path="mailer/activation.en.text.plain.erb">

I attach the patch to fix this behaviour. I couldn't figure out where the tests for ActionView::Template are located thus lack of thereof.

Reported by Mateusz Drożdżyński · March 18th, 2009 @ 10:43 AM

State: resolved
Milestone: 2.x
Assigned to: josh josh
Importance: none

Activity

  1. Eloy Duran
    Eloy Duran
    • Assigned user set to josh

    I couldn't figure out where the tests for ActionView::Template are located thus lack of thereof.

    You are right, there are none yet. Please add a failing unit test which tests the #split method.

    I can imagine something like the following (untested code):

    
    test "filename parsing" do
      ["template.en.text.plain.erb", :name => 'template', :extension => 'erb', :format => 'text', :locale => 'en'].each do |file, expected|
        template = ActionView::Template.new(file)
        expected.each do |name, value|
          assert_equal value, template.send(name)
        end
      end
    end
    

    March 18th, 2009 @ 12:57 PM

  2. Mateusz Drożdżyński
    Mateusz Drożdżyński

    I'd be glad to add a test to cover my patch yet I still can't find any reasonable file to put it in. Any suggestions? I couldn't find any other tests that would test the #split method.

    March 19th, 2009 @ 07:08 PM

  3. thedarkone
    thedarkone

    I rewrote extension parsing in #2315 ActionView::Template extension processing bug. Mateusz, your issue should be automaticaly fixed as well.

    March 24th, 2009 @ 12:31 AM

  4. Repository
    Repository
    • State changed from new to resolved

    (from [6a1267a0b12560a752ebfb443194de1a0ab3bef5]) Fix template extension parsing. [#2315 ActionView::Template extension processing bug state:resolved] [#2284 ActionView::Template doesn't support multipart formats with locale state:resolved]

    Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...

    March 24th, 2009 @ 03:54 PM

  5. Repository
    Repository

    (from [ae9f258e03c9fd5088da12c1c6cd216cc89a01f7]) Fix template extension parsing. [#2315 ActionView::Template extension processing bug state:resolved] [#2284 ActionView::Template doesn't support multipart formats with locale state:resolved]

    Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...

    March 24th, 2009 @ 03:54 PM