
Option not found in select box when not using english month names
Reported by Emilio Tagua | March 17th, 2009 @ 02:13 PM
I'm using Cucumber + webrat, and writing features in Spanish, the Rails app is translated with built-in i18n.
The problem, if it's a real problem or maybe it's just me, is that i get this error when trying to chose from a datetime select:
The 'November' option was not found in the "site_baby_attributes_date_of_birth_2i" select box (Webrat::NotFoundError)
The feature line that raises this is:
Y selecciono "Noviembre 25, 2000 10:30" como la fecha y hora de "Mi fecha de nacimiento"
Now webrat in select_date makes use of date.strftime('%B') to pick up the month names, the problem is that this will ignore other language names because it uses system format.
I monkey-patched this in my app to get a temporary solution but maybe it's a good idea to get this changed to better solution for any locale.
Comments and changes to this ticket
-
gaffo May 7th, 2009 @ 05:22 PM
- Tag changed from select_date to il8n, select_date
- State changed from new to open
It would be quite if you could provide what the html looks like in spanish for the dropdown and a test line that fails. This will help us debug it much easier.
-
Rune Botten May 14th, 2009 @ 10:46 PM
- Tag changed from il8n, select_date to il8n, patch, select_date
The problem is that Webrat is comparing strftime('%B') against whatever is in the select option. Many languages will not capitalize month names the way english do, and since %B will give 'April', then the Rails I18n generated april will not be found.
I've attached a patch to do the select option lookups case insensitive, which fixes this issue and does not seem to break anything.
-
gaffo May 15th, 2009 @ 10:54 AM
- Tag changed from il8n, patch, select_date to il8n, patch, select_date, verify
- State changed from open to awaiting-merge
Patch looks good. Need to verify and pull in.
-
Guillermo Álvarez July 8th, 2009 @ 11:59 AM
These is a duplication of: https://webrat.lighthouseapp.com/projects/10503/tickets/138-select_...
That ticket have a test case.
I upload a new rails template with webrat from dchelimsky insted of brynari.
I tried the patch and it doesn't work in any manner.
The problem is that webrat:
a) Doesn't know in wich locale the rails app is running.
b) Doesn't know how to parse other languages dates.
c) Doesn't know convert from name to other locale.Emilio, try the code in the original ticket, it makes a manual select, but it works as expected.
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
The patch necessary to solve these, probably might be bigger.
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.
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.