Sha256: ff48ed67b545777d729f87227d7cf66a501046b2257d5e0c5b3294dd05e1b916

Contents?: true

Size: 1.72 KB

Versions: 4

Compression:

Stored size: 1.72 KB

Contents

require 'test_helper'

class SelectTest < ViewCase

  setup :sign_in
  teardown :teardown

  def test_select_with_active_record_collection
    # test permission, which proc in options gives an
    # activerecord array as a response.

    visit adminpanel.new_permission_path

    select_selector = find('#permission_role_id')

    assert select_selector.find('option', text: 'Admin')
    assert select_selector.find('option', text: 'Superuser')
    assert select_selector.find('option', text: 'Deleter')
    assert select_selector.find('option', text: 'Reader')
    assert select_selector.find('option', text: 'Updater')
    assert select_selector.find('option', text: 'Creator')
    assert select_selector.find('option', text: 'Publisher')
  end

  def test_select_with_diffent_name_method
    # test select, with a name method different than the default
    visit adminpanel.new_salesman_path
    # puts page.
    select_field = find('#salesman_product_id')
    assert select_field
    assert select_field.find('option', text: adminpanel_products(:first).supername)
    assert select_field.find('option', text: adminpanel_products(:limit_images).supername)
  end

  def test_select_with_multiple_option_should_create_select2
    visit adminpanel.new_category_path
    assert has_selector?('select[data-adminpanel-select2][multiple]', visible: false)
    assert has_selector?('span.select2')

  end

  def test_select_with_grouped_should_render_optgroup
    visit adminpanel.new_category_path

    select_field = find('select[data-adminpanel-select2][multiple]', visible: false)

    assert select_field
    assert select_field.has_selector?('optgroup', visible: false)
  end

  private
    def sign_in
      visit adminpanel.signin_path
      login
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
adminpanel-3.6.1 test/features/shared/form/select_test.rb
adminpanel-3.6.0 test/features/shared/form/select_test.rb
adminpanel-3.5.1 test/features/shared/form/select_test.rb
adminpanel-3.5.0 test/features/shared/form/select_test.rb