2011-06-27 18:31:03 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
2013-01-23 01:17:17 +00:00
|
|
|
class DeviseHelperTest < ActionDispatch::IntegrationTest
|
2011-06-27 18:31:03 +00:00
|
|
|
setup do
|
2011-08-04 18:38:42 +00:00
|
|
|
model_labels = { :models => { :user => "utilisateur" } }
|
|
|
|
|
2011-06-27 18:31:03 +00:00
|
|
|
I18n.backend.store_translations :fr,
|
|
|
|
{
|
|
|
|
:errors => { :messages => { :not_saved => {
|
|
|
|
:one => "Erreur lors de l'enregistrement de '%{resource}': 1 erreur.",
|
|
|
|
:other => "Erreur lors de l'enregistrement de '%{resource}': %{count} erreurs."
|
|
|
|
} } },
|
2011-08-04 18:38:42 +00:00
|
|
|
:activerecord => model_labels,
|
|
|
|
:mongoid => model_labels
|
2011-06-27 18:31:03 +00:00
|
|
|
}
|
2011-06-28 10:05:35 +00:00
|
|
|
|
2011-06-27 18:31:03 +00:00
|
|
|
I18n.locale = 'fr'
|
|
|
|
end
|
2011-06-28 10:05:35 +00:00
|
|
|
|
|
|
|
teardown do
|
|
|
|
I18n.locale = 'en'
|
|
|
|
end
|
|
|
|
|
2011-06-27 18:31:03 +00:00
|
|
|
test 'test errors.messages.not_saved with single error from i18n' do
|
|
|
|
get new_user_registration_path
|
2011-06-28 10:05:35 +00:00
|
|
|
|
2011-06-27 18:31:03 +00:00
|
|
|
fill_in 'password', :with => 'new_user123'
|
|
|
|
fill_in 'password confirmation', :with => 'new_user123'
|
|
|
|
click_button 'Sign up'
|
|
|
|
|
|
|
|
assert_have_selector '#error_explanation'
|
|
|
|
assert_contain "Erreur lors de l'enregistrement de 'utilisateur': 1 erreur"
|
|
|
|
end
|
2011-06-28 10:05:35 +00:00
|
|
|
|
2011-06-27 18:31:03 +00:00
|
|
|
test 'test errors.messages.not_saved with multiple errors from i18n' do
|
2011-08-04 18:38:42 +00:00
|
|
|
# Dirty tracking behavior prevents email validations from being applied:
|
|
|
|
# https://github.com/mongoid/mongoid/issues/756
|
|
|
|
(pending "Fails on Mongoid < 2.1"; break) if defined?(Mongoid) && Mongoid::VERSION.to_f < 2.1
|
|
|
|
|
2011-06-27 18:31:03 +00:00
|
|
|
get new_user_registration_path
|
2011-06-28 10:05:35 +00:00
|
|
|
|
2011-06-27 18:31:03 +00:00
|
|
|
fill_in 'email', :with => 'invalid_email'
|
|
|
|
fill_in 'password', :with => 'new_user123'
|
|
|
|
fill_in 'password confirmation', :with => 'new_user321'
|
|
|
|
click_button 'Sign up'
|
|
|
|
|
|
|
|
assert_have_selector '#error_explanation'
|
|
|
|
assert_contain "Erreur lors de l'enregistrement de 'utilisateur': 2 erreurs"
|
|
|
|
end
|
2011-08-04 18:38:42 +00:00
|
|
|
end
|
|
|
|
|