1.9 hash syntax
This commit is contained in:
parent
ef81ffe713
commit
58ce72b99f
|
@ -97,65 +97,65 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should translate include blank when set to :translate' do
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
store_translations(:en, simple_form: { include_blanks: { user: {
|
||||
age: 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => :translate
|
||||
with_input_for @user, :age, :select, collection: 18..30, include_blank: :translate
|
||||
assert_select 'select option[value=]', 'Rather not say'
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should translate include blank when set to :t' do
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
store_translations(:en, simple_form: { include_blanks: { user: {
|
||||
age: 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => :t
|
||||
with_input_for @user, :age, :select, collection: 18..30, include_blank: :t
|
||||
assert_select 'select option[value=]', 'Rather not say'
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should translate include blank with a particular key' do
|
||||
store_translations(:en, :simple_form => { :include_blanks => {
|
||||
:age => 'Rather not say',
|
||||
:user => { :age => 'Should be overridden' }
|
||||
store_translations(:en, simple_form: { include_blanks: {
|
||||
age: 'Rather not say',
|
||||
user: { age: 'Should be overridden' }
|
||||
} } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => :age
|
||||
with_input_for @user, :age, :select, collection: 18..30, include_blank: :age
|
||||
assert_select 'select option[value=]', 'Rather not say'
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should not translate include blank when set to a string' do
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
store_translations(:en, simple_form: { include_blanks: { user: {
|
||||
age: 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => 'Young at heart'
|
||||
with_input_for @user, :age, :select, collection: 18..30, include_blank: 'Young at heart'
|
||||
assert_select 'select option[value=]', 'Young at heart'
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should not translate include blank when automatically set' do
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
store_translations(:en, simple_form: { include_blanks: { user: {
|
||||
age: 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30
|
||||
with_input_for @user, :age, :select, collection: 18..30
|
||||
assert_select 'select option[value=]', ''
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should not translate include blank when set to true' do
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
store_translations(:en, simple_form: { include_blanks: { user: {
|
||||
age: 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => true
|
||||
with_input_for @user, :age, :select, collection: 18..30, include_blank: true
|
||||
assert_select 'select option[value=]', ''
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should not translate include blank when set to false' do
|
||||
store_translations(:en, :simple_form => { :include_blanks => { :user => {
|
||||
:age => 'Rather not say'
|
||||
store_translations(:en, simple_form: { include_blanks: { user: {
|
||||
age: 'Rather not say'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => false
|
||||
with_input_for @user, :age, :select, collection: 18..30, include_blank: false
|
||||
assert_no_select 'select option[value=]'
|
||||
end
|
||||
end
|
||||
|
@ -176,56 +176,56 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'input should translate prompt when set to :translate' do
|
||||
store_translations(:en, :simple_form => { :prompts => { :user => {
|
||||
:age => 'Select age:'
|
||||
store_translations(:en, simple_form: { prompts: { user: {
|
||||
age: 'Select age:'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :prompt => :translate
|
||||
with_input_for @user, :age, :select, collection: 18..30, prompt: :translate
|
||||
assert_select 'select option[value=]', 'Select age:'
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should translate prompt when set to :t' do
|
||||
store_translations(:en, :simple_form => { :prompts => { :user => {
|
||||
:age => 'Select age:'
|
||||
store_translations(:en, simple_form: { prompts: { user: {
|
||||
age: 'Select age:'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :prompt => :t
|
||||
with_input_for @user, :age, :select, collection: 18..30, prompt: :t
|
||||
assert_select 'select option[value=]', 'Select age:'
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should translate prompt with a particular key' do
|
||||
store_translations(:en, :simple_form => { :prompts => {
|
||||
:age => 'Select age:',
|
||||
:user => { :age => 'Should be overridden' }
|
||||
store_translations(:en, simple_form: { prompts: {
|
||||
age: 'Select age:',
|
||||
user: { age: 'Should be overridden' }
|
||||
} } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :prompt => :age
|
||||
with_input_for @user, :age, :select, collection: 18..30, prompt: :age
|
||||
assert_select 'select option[value=]', 'Select age:'
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should not translate prompt when set to a string' do
|
||||
store_translations(:en, :simple_form => { :prompts => { :user => {
|
||||
:age => 'Select age:'
|
||||
store_translations(:en, simple_form: { prompts: { user: {
|
||||
age: 'Select age:'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :prompt => 'Do it:'
|
||||
with_input_for @user, :age, :select, collection: 18..30, prompt: 'Do it:'
|
||||
assert_select 'select option[value=]', 'Do it:'
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should not translate prompt when set to false' do
|
||||
store_translations(:en, :simple_form => { :prompts => { :user => {
|
||||
:age => 'Select age:'
|
||||
store_translations(:en, simple_form: { prompts: { user: {
|
||||
age: 'Select age:'
|
||||
} } } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :prompt => false
|
||||
with_input_for @user, :age, :select, collection: 18..30, prompt: false
|
||||
assert_no_select 'select option[value=]'
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should use Rails prompt translation as a fallback' do
|
||||
store_translations(:en, :helpers => { :select => {
|
||||
:prompt => 'Select value:'
|
||||
store_translations(:en, helpers: { select: {
|
||||
prompt: 'Select value:'
|
||||
} } ) do
|
||||
with_input_for @user, :age, :select, :collection => 18..30, :prompt => :translate
|
||||
with_input_for @user, :age, :select, collection: 18..30, prompt: :translate
|
||||
assert_select 'select option[value=]', "Select value:"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue