Sha256: 631edb47b062add1bc495d5d22a4a6173404f457aa4838880e62459911b527f9

Contents?: true

Size: 795 Bytes

Versions: 6

Compression:

Stored size: 795 Bytes

Contents

require 'test_helper'

class HelperTest < ActionView::TestCase
  include StorageHelper

  test 'fields for' do
    product = Product.create(pictures: [image])
    product.run_callbacks :commit
    product.pictures.build

    html = form_for(product, url: 'test') do |f|
      f.fields_for(:pictures) do |ff|
        ff.file_field(:value) +
        ff.number_field(:position)
      end
    end

    assert html.include?('[pictures_attributes][0][id]')
    assert html.include?('[pictures_attributes][0][value]')
    assert html.include?('[pictures_attributes][0][position]')
    assert html.exclude?('[pictures_attributes][1][id]')
    assert html.include?('[pictures_attributes][1][value]')
    assert html.include?('[pictures_attributes][1][position]')

    product.pictures.destroy
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
attachs-4.0.0.5 test/helper_test.rb
attachs-4.0.0.4 test/helper_test.rb
attachs-4.0.0.3 test/helper_test.rb
attachs-4.0.0.2 test/helper_test.rb
attachs-4.0.0.1 test/helper_test.rb
attachs-4.0.0.0 test/helper_test.rb