Sha256: 32561f2b5989d323868b89453b052a23e3342d4e2208d1e59f62477c7a8eaf50

Contents?: true

Size: 687 Bytes

Versions: 6

Compression:

Stored size: 687 Bytes

Contents

require 'test_helper'

class WriteableTest < MiniTest::Spec # TODO: remove me in 2.0.
  Location = Struct.new(:country)

  class LocationForm < Reform::Form
    reform_2_0!

    property :country, writeable: false
  end

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

  it { form.country.must_equal "Australia" }
  it do
    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

6 entries across 6 versions & 1 rubygems

Version Path
reform-1.2.6 test/writeable_test.rb
reform-1.2.5 test/writeable_test.rb
reform-1.2.4 test/writeable_test.rb
reform-1.2.3 test/writeable_test.rb
reform-1.2.2 test/writeable_test.rb
reform-1.2.1 test/writeable_test.rb