2009-12-08 12:59:50 -05:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class ErrorTest < ActionView::TestCase
|
|
|
|
|
2009-12-08 13:58:38 -05:00
|
|
|
test 'input should not generate a hint by default' do
|
|
|
|
simple_form_for @user do |f|
|
|
|
|
concat f.input :name
|
|
|
|
end
|
|
|
|
assert_no_select 'form span.hint'
|
|
|
|
end
|
|
|
|
|
2009-12-08 12:59:50 -05:00
|
|
|
test 'input should allow generating a hint' do
|
|
|
|
simple_form_for @user do |f|
|
|
|
|
concat f.input :name, :hint => 'Use with care...'
|
|
|
|
end
|
|
|
|
assert_select 'form span.hint', 'Use with care...'
|
|
|
|
end
|
2009-12-08 13:03:31 -05:00
|
|
|
|
2009-12-08 13:58:38 -05:00
|
|
|
test 'input should use i18n to find hints based on model and attribute' do
|
|
|
|
store_translations(:en, :simple_form => { :hints => { :user => { :name =>
|
|
|
|
'Content of this input will be capitalized...'
|
|
|
|
} } }) do
|
|
|
|
simple_form_for @user do |f|
|
|
|
|
concat f.input :name
|
|
|
|
end
|
|
|
|
assert_select 'form span.hint', 'Content of this input will be capitalized...'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'input should use i18n based only on attribute to pick up the label translation' do
|
|
|
|
store_translations(:en, :simple_form => { :hints => { :name => 'Name hint!' } } ) do
|
|
|
|
simple_form_for @user do |f|
|
|
|
|
concat f.input :name
|
|
|
|
end
|
|
|
|
assert_select 'form span.hint', 'Name hint!'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'input should allow disabling a hint that exists in i18n' do
|
|
|
|
store_translations(:en, :simple_form => { :hints => { :name => 'Name hint!' } } ) do
|
|
|
|
simple_form_for @user do |f|
|
|
|
|
concat f.input :name, :hint => false
|
|
|
|
end
|
|
|
|
assert_no_select 'form span.hint'
|
2009-12-08 13:03:31 -05:00
|
|
|
end
|
|
|
|
end
|
2009-12-09 06:38:51 -05:00
|
|
|
|
|
|
|
test 'hint should not be generated for hidden fields' do
|
|
|
|
simple_form_for @user do |f|
|
|
|
|
concat f.input :name, :hint => 'Bla bla bla', :as => :hidden
|
|
|
|
end
|
|
|
|
assert_no_select 'form span.hint'
|
|
|
|
end
|
2009-12-08 12:59:50 -05:00
|
|
|
end
|