#138 awaiting-patch
Guillermo Álvarez

select_date fails with localized rails app

Reported by Guillermo Álvarez | January 21st, 2009 @ 08:09 AM

In a spanish localizated 2.2 rails app, i want to fill some date_select form.

In webrat i write select_date(date, :from => date_label)

But it fails, because webrat search for the month name in english, and it is in spanihs.

In a cucumber output, i can see


      And I select "23 Jun 1983" as the "Fecha de nacimiento" date  # features/step_definitions/webrat_steps.rb:65
      The 'June' option was not found in the "candidate_birthdate_2i" select box (Webrat::NotFoundError)
      /Library/Ruby/Gems/1.8/gems/brynary-webrat-0.4.0/lib/webrat/core/locators/locator.rb:14:in `locate!'

Comments and changes to this ticket

  • Guillermo Álvarez

    Guillermo Álvarez January 21st, 2009 @ 10:25 AM

    • Title changed from “select_date fails with localize rails app” to “select_date fails with localized rails app”
  • Guillermo Álvarez

    Guillermo Álvarez January 21st, 2009 @ 11:43 AM

    I update my cucumber steps as follow

    
    When /^I select "(.*)" as the "(.*)" date$/ do |date, date_label|  
      day,month,year = date.split(' ')
      
      select year, :from => "#{date_label}_1i"
      select month, :from => "#{date_label}_2i"
      select day, :from => "#{date_label}_3i"
    end
    

    And in the feature

    
        And I select "23 Abril 1983" as the "candidate_birthdate" date
    

    The problem is that i can't find the id by label because Webrat::Scope#locate_id_prefix is a protected method.

    But it works just fine

  • Bryan Helmkamp

    Bryan Helmkamp February 8th, 2009 @ 11:48 PM

    • Tag changed from localize, rails2.2, select_date to featurerequest, localize, rails2.2, select_date
    • State changed from “new” to “open”

    Hmm... So it seems the way to work around this would be to make select_date depend on the field values instead of the month name (4 instead of April).

    Care to take a stab at a patch?

  • gaffo

    gaffo June 3rd, 2009 @ 10:17 AM

    • Tag changed from featurerequest, localize, rails2.2, select_date to featurerequest, localize, rails2.2, select_date, stale

    Guillermo Álvarez,
    Is this still an issue?

  • Guillermo Álvarez

    Guillermo Álvarez June 3rd, 2009 @ 10:53 AM

    Let me one or two days to check it again.

  • Guillermo Álvarez

    Guillermo Álvarez June 4th, 2009 @ 06:55 PM

    I attach a rails template that simulates all the problem.

    Just run

    rails date_select_test -m webrat_test.rb

    The template will run test first without localization and next with localization.

    I think webrat_test.rb template can be self explained.

  • gaffo

    gaffo June 4th, 2009 @ 07:26 PM

    • Tag changed from featurerequest, localize, rails2.2, select_date, stale to featurerequest, localize, rails2.2, select_date, verify
    • State changed from “open” to “awaiting-patch”
  • José Valim

    José Valim July 26th, 2009 @ 10:31 AM

    I can work on a patch for that. We have two options:

    1) Use I18n when using Rails;

    select I18n.t('date.month_names')[date.mon], :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:month]}"
    

    2) Or as Bryan said, select an option using its value. In this case, there is a method that already does this?

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

Attachments

Referenced by

Pages