Sha256: ec1f545534fd532892a935ec6c18206ff985c77b9b9ea7a5eb1add889638c807
Contents?: true
Size: 1.1 KB
Versions: 4
Compression:
Stored size: 1.1 KB
Contents
require "test_helper" require "reform/form/coercion" class ChangedTest < MiniTest::Spec Song = Struct.new(:title, :album, :composer) Album = Struct.new(:name, :songs, :artist) Artist = Struct.new(:name) class AlbumForm < TestForm property :name collection :songs do property :title property :composer do property :name end end end let(:song_with_composer) { Song.new("Resist Stance", nil, composer) } let(:composer) { Artist.new("Greg Graffin") } let(:album) { Album.new("The Dissent Of Man", [song_with_composer]) } let(:form) { AlbumForm.new(album) } # nothing changed after setup. it do refute form.changed?(:name) refute form.songs[0].changed?(:title) refute form.songs[0].composer.changed?(:name) end # after validate, things might have changed. it do form.validate("name" => "Out Of Bounds", "songs" => [{"composer" => {"name" => "Ingemar Jansson & Mikael Danielsson"}}]) assert form.changed?(:name) refute form.songs[0].changed?(:title) assert form.songs[0].composer.changed?(:name) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
reform-2.6.2 | test/changed_test.rb |
reform-2.6.1 | test/changed_test.rb |
reform-2.6.0 | test/changed_test.rb |
reform-2.5.0 | test/changed_test.rb |