Sha256: 5d33350915a79b4b89d1e9324434afb238ef8359ffa3afc40e62040e64b95a70
Contents?: true
Size: 638 Bytes
Versions: 4
Compression:
Stored size: 638 Bytes
Contents
require "test_helper" class PopulatorSkipTest < MiniTest::Spec Album = Struct.new(:songs) Song = Struct.new(:title) class AlbumForm < TestForm collection :songs, populator: :my_populator do property :title end def my_populator(options) return skip! if options[:fragment][:title] == "Good" songs[options[:index]] end end it do form = AlbumForm.new(Album.new([Song.new, Song.new])) hash = {songs: [{title: "Good"}, {title: "Bad"}]} form.validate(hash) assert_equal form.songs.size, 2 assert_nil form.songs[0].title assert_equal form.songs[1].title, "Bad" end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
reform-2.6.2 | test/populator_skip_test.rb |
reform-2.6.1 | test/populator_skip_test.rb |
reform-2.6.0 | test/populator_skip_test.rb |
reform-2.5.0 | test/populator_skip_test.rb |