Sha256: beb1d948ddc4199ab4210ec6401bc581a866c67b854de9420f33e5b76abaa8d0

Contents?: true

Size: 1.47 KB

Versions: 20

Compression:

Stored size: 1.47 KB

Contents

# encoding: UTF-8
require 'test_helper'

class ButtonTest < ActionView::TestCase
  def with_button_for(object, *args)
    with_concat_form_for(object) do |f|
      f.button(*args)
    end
  end

  test 'builder should create buttons' do
    with_button_for :post, :submit
    assert_select 'form input.button[type=submit][value=Save Post]'
  end

  test 'builder should create buttons with options' do
    with_button_for :post, :submit, :class => 'my_button'
    assert_select 'form input.button.my_button[type=submit][value=Save Post]'
  end

  test 'builder should not modify the options hash' do
    options = { :class => 'my_button' }
    with_button_for :post, :submit, options
    assert_select 'form input.button.my_button[type=submit][value=Save Post]'
    assert_equal({ :class => 'my_button' }, options)
  end

  test 'builder should create buttons for records' do
    @user.new_record!
    with_button_for @user, :submit
    assert_select 'form input.button[type=submit][value=Create User]'
  end

  test "builder should use the default class from the configuration" do
    swap SimpleForm, :button_class => 'btn' do
      with_button_for :post, :submit
      assert_select 'form input.btn[type=submit][value=Save Post]'
    end
  end

  if ActionView::Helpers::FormBuilder.method_defined?(:button)
    test "allows to use Rails button helper when available" do
      with_button_for :post, :button, 'Save!'
      assert_select 'form button.button[type=submit]', 'Save!'
    end
  end
end

Version data entries

20 entries across 20 versions & 4 rubygems

Version Path
simple_form-2.1.3 test/form_builder/button_test.rb
simple_form-2.1.2 test/form_builder/button_test.rb
simple_form-2.1.1 test/form_builder/button_test.rb
simple_form_awesome-2.5.0 test/form_builder/button_test.rb
simple_form_awesome-2.4.0 test/form_builder/button_test.rb
simple_form_awesome-2.3.0 test/form_builder/button_test.rb
simple_form_awesome-2.2.0 test/form_builder/button_test.rb
simple_form-2.1.0 test/form_builder/button_test.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/simple_form-2.0.4/test/form_builder/button_test.rb
simple_form-2.0.4 test/form_builder/button_test.rb
simple_form-2.0.3 test/form_builder/button_test.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/simple_form-2.0.2/test/form_builder/button_test.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/simple_form-2.0.2/test/form_builder/button_test.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/simple_form-2.0.2/test/form_builder/button_test.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/simple_form-2.0.2/test/form_builder/button_test.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/simple_form-2.0.2/test/form_builder/button_test.rb
simple_form-2.0.2 test/form_builder/button_test.rb
ehoch_simple_form-2.0.2.dev test/form_builder/button_test.rb
simple_form-2.0.1 test/form_builder/button_test.rb
simple_form-2.0.0 test/form_builder/button_test.rb