Sha256: 25693c6192f1703042ad9fed544cfc1f914170757615daa1a097ba59b9045ac6

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

# encoding: UTF-8
require 'test_helper'

class TextInputTest < ActionView::TestCase
  test 'input generates a text area for text attributes' do
    with_input_for @user, :description, :text
    assert_select 'textarea.text#user_description'
  end

  test 'input generates a text area for text attributes that accept placeholder' do
    with_input_for @user, :description, :text, placeholder: 'Put in some text'
    assert_select 'textarea.text[placeholder="Put in some text"]'
  end

  test 'input generates a placeholder from the translations' do
    store_translations(:en, simple_form: { placeholders: { user: { name: "placeholder from i18n en.simple_form.placeholders.user.name" } } }) do
      with_input_for @user, :name, :text
      assert_select 'textarea.text[placeholder="placeholder from i18n en.simple_form.placeholders.user.name"]'
    end
  end

  test 'input gets maxlength from column definition for text attributes' do
    with_input_for @user, :description, :text
    assert_select 'textarea.text[maxlength="200"]'
  end

  test 'input infers maxlength column definition from validation when present for text attributes' do
    with_input_for @validating_user, :description, :text
    assert_select 'textarea.text[maxlength="50"]'
  end

  test 'input infers minlength column definition from validation when present for text attributes' do
    with_input_for @validating_user, :description, :text
    assert_select 'textarea.text[minlength="15"]'
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
simple_form-3.5.0 test/inputs/text_input_test.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/simple_form-3.4.0/test/inputs/text_input_test.rb
simple_form-3.4.0 test/inputs/text_input_test.rb