Sha256: 4c7f5707034e2ed22c20108a62326e12267eed4d5062ff6b79348694ee304593

Contents?: true

Size: 640 Bytes

Versions: 19

Compression:

Stored size: 640 Bytes

Contents

require 'test_helper'

class WriteableTest < MiniTest::Spec
  Location = Struct.new(:country)

  class LocationForm < Reform::Form
    property :country, writeable: false
  end

  let (:loc) { Location.new("Australia") }
  let (:form) { LocationForm.new(loc) }

  it do
    form.country.must_equal "Australia"

    form.validate("country" => "Germany") # this usually won't change when submitting.
    form.country.must_equal "Germany"

    form.sync
    loc.country.must_equal "Australia" # the writer wasn't called.

    hash = {}
    form.save do |nested|
      hash = nested
    end

    hash.must_equal("country"=> "Germany")
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
reform-2.2.4 test/writeable_test.rb
reform-2.2.3 test/writeable_test.rb
reform-2.2.2 test/writeable_test.rb
reform-2.2.1 test/writeable_test.rb
reform-2.2.0 test/writeable_test.rb
reform-2.2.0.rc1 test/writeable_test.rb
reform-2.1.0 test/writeable_test.rb
reform-2.1.0.rc1 test/writeable_test.rb
reform-2.0.5 test/writeable_test.rb
reform-2.0.4 test/writeable_test.rb
reform-2.0.3 test/writeable_test.rb
reform-2.0.2 test/writeable_test.rb
reform-2.0.1 test/writeable_test.rb
reform-2.0.0 test/writeable_test.rb
reform-2.0.0.rc3 test/writeable_test.rb
reform-2.0.0.rc2 test/writeable_test.rb
reform-2.0.0.rc1 test/writeable_test.rb
reform-2.0.0.beta2 test/writeable_test.rb
reform-2.0.0.beta1 test/writeable_test.rb