reform 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8d0dc76658a132e15bea8612f35e7bfa77fb7b8
4
- data.tar.gz: 31226f61d63c42b0a641b5592eb9714cb29bcff2
3
+ metadata.gz: 1a65ba4e715246d4be150394d9ee6fbcd34af3e8
4
+ data.tar.gz: 8c12fd32b88fd52a7c20cbe2cf84f5a6bbf01c8d
5
5
  SHA512:
6
- metadata.gz: cde409c7fa9dc9054d05e2dafb7cf672abf8585d85b97f05f8f0d37b0d6c0de25e554775fb7a8a5eec57567977ba8ff03cdcb2276190c964e5f62c31259ce027
7
- data.tar.gz: 70ac7b9421a13e0936ba9e149f611ad9f540b071f1f557d474a191c9c1d4a7e2a8fc126a9510a7fed65b1ef70078033ea4e8f34a6d9d2bc3dd9b74fbc61bd1c3
6
+ metadata.gz: 922aee7abf462ddcc510ffcce88f90a88d6450586df3c9eed27e174f5c6f73a8c6e43022147a6b730daa61fd61016bf3e97f620458546d5da5e5c6d30f134c68
7
+ data.tar.gz: b752b34d4a88ab8ac02f594635fc793ea3f7d0f39c139971d1d944d26109aa921196b46242febbd7b68ea478e87e8b12cd06b0fe1765391b427cbfd0c7216a39
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.2.2
2
+
3
+ * Use new `uber` to allow subclassing `reform_2_0!` forms.
4
+ * Raise a better understandable deserialization error when the form is not populated properly. This error is so common that I overcame myself to add a dreaded `rescue` block in `Form#validate`.
5
+
1
6
  ## 1.2.1
2
7
 
3
8
  * Fixed a nasty bug where `ActiveModel` forms with form builder support wouldn't deserialize properly. A million Thanks to @karolsarnacki for finding this and providing an exemplary failing test. <3
data/README.md CHANGED
@@ -4,6 +4,13 @@ Decouple your models from forms. Reform gives you a form object with validations
4
4
 
5
5
  Although reform can be used in any Ruby framework, it comes with [Rails support](#rails-integration), works with [simple_form and other form gems](#formbuilder-support), allows nesting forms to implement [has_one](#nesting-forms-1-1-relations) and [has_many](#nesting-forms-1-n-relations) relationships, can [compose a form](#compositions) from multiple objects and gives you [coercion](#coercion).
6
6
 
7
+ <a href="https://leanpub.com/trailblazer">
8
+ ![](https://raw.githubusercontent.com/apotonick/trailblazer/master/doc/trb.jpg)
9
+ </a>
10
+
11
+ Reform is part of the [Trailblazer project](https://github.com/apotonick/trailblazer). Please [buy my book](https://leanpub.com/trailblazer) to support the development (and to learn all the cool stuff about Reform).
12
+
13
+
7
14
  ## Installation
8
15
 
9
16
  Add this line to your Gemfile:
@@ -664,7 +671,7 @@ When you want to show a value but skip processing it after submission the `:writ
664
671
 
665
672
  ```ruby
666
673
  class ProfileForm < Reform::Form
667
- property :country, :writeable => false
674
+ property :country, writeable: false
668
675
  ```
669
676
 
670
677
  This time reform will query the model for the value by calling `model.country`.
@@ -683,7 +690,7 @@ form.save do |nested|
683
690
  A third alternative is to hide a field's value but write it to the database when syncing. This can be achieved using the `:readable` option.
684
691
 
685
692
  ```ruby
686
- property :credit_card_number, :readable => false
693
+ property :credit_card_number, readable: false
687
694
  ```
688
695
 
689
696
  ## Validations From Models
data/database.sqlite3 CHANGED
Binary file
@@ -12,8 +12,6 @@ class Reform::Contract::Errors < ActiveModel::Errors
12
12
  # end
13
13
 
14
14
  def merge!(errors, prefix)
15
- prefixes = prefix.join(".")
16
-
17
15
  # TODO: merge into AM.
18
16
  errors.messages.each do |field, msgs|
19
17
  unless field.to_sym == :base
@@ -36,4 +34,4 @@ class Reform::Contract::Errors < ActiveModel::Errors
36
34
  def to_s
37
35
  messages.inspect
38
36
  end
39
- end # Errors
37
+ end # Errors
@@ -75,6 +75,9 @@ module Reform::Form::Validate
75
75
  update!(params)
76
76
 
77
77
  super() # run the actual validation on self.
78
+
79
+ rescue Representable::DeserializeError
80
+ raise DeserializeError.new("[Reform] Deserialize error: You probably called #validate without setting up your nested models. Check https://github.com/apotonick/reform#populating-forms-for-validation on how to use populators.")
78
81
  end
79
82
 
80
83
  # Some users use this method to pre-populate a form. Not saying this is right, but we'll keep
@@ -129,4 +132,7 @@ private
129
132
  dfn.merge!(:parse_filter => Changed.new) unless dfn[:form] # TODO: make changed? work for nested forms.
130
133
  end
131
134
  end
135
+
136
+ class DeserializeError < RuntimeError
137
+ end
132
138
  end
@@ -1,3 +1,3 @@
1
1
  module Reform
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  end
data/reform.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency "representable", "~> 2.1.0"
22
22
  spec.add_dependency "disposable", "~> 0.0.5"
23
- spec.add_dependency "uber", "~> 0.0.8"
23
+ spec.add_dependency "uber", "~> 0.0.11"
24
24
  spec.add_dependency "activemodel"
25
25
  spec.add_development_dependency "bundler", "~> 1.3"
26
26
  spec.add_development_dependency "rake"
@@ -37,6 +37,14 @@ class ValidateTest < BaseTest
37
37
  it { song2.title.must_equal nil }
38
38
  end
39
39
 
40
+ describe "not populated properly raises error" do
41
+ it do
42
+ assert_raises Reform::Form::Validate::DeserializeError do
43
+ AlbumForm.new(Album.new).validate("hit" => {"title" => "Roxanne"})
44
+ end
45
+ end
46
+ end
47
+
40
48
  # TODO: the following tests go to populate_test.rb
41
49
  describe "manual setup with populator" do
42
50
  let (:form) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reform
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-07 00:00:00.000000000 Z
12
+ date: 2014-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: representable
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 0.0.8
48
+ version: 0.0.11
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 0.0.8
55
+ version: 0.0.11
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: activemodel
58
58
  requirement: !ruby/object:Gem::Requirement