reform 1.2.0.beta2 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+
3
+ class WriteableTest < MiniTest::Spec # TODO: remove me in 2.0.
4
+ Location = Struct.new(:country)
5
+
6
+ class LocationForm < Reform::Form
7
+ reform_2_0!
8
+
9
+ property :country, writeable: false
10
+ end
11
+
12
+ let (:loc) { Location.new("Australia") }
13
+ let (:form) { LocationForm.new(loc) }
14
+
15
+ it { form.country.must_equal "Australia" }
16
+ it do
17
+ form.validate("country" => "Germany") # this usually won't change when submitting.
18
+ form.country.must_equal "Germany"
19
+
20
+ form.sync
21
+ loc.country.must_equal "Australia" # the writer wasn't called.
22
+
23
+ hash = {}
24
+ form.save do |nested|
25
+ hash = nested
26
+ end
27
+
28
+ hash.must_equal("country"=> "Germany")
29
+ end
30
+ end
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.0.beta2
4
+ version: 1.2.1
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-05 00:00:00.000000000 Z
12
+ date: 2014-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: representable
@@ -230,7 +230,7 @@ files:
230
230
  - reform.gemspec
231
231
  - test/active_model_test.rb
232
232
  - test/active_record_test.rb
233
- - test/as_test.rb
233
+ - test/benchmarking.rb
234
234
  - test/builder_test.rb
235
235
  - test/changed_test.rb
236
236
  - test/coercion_test.rb
@@ -268,12 +268,14 @@ files:
268
268
  - test/form_builder_test.rb
269
269
  - test/form_composition_test.rb
270
270
  - test/form_test.rb
271
+ - test/from_test.rb
271
272
  - test/inherit_test.rb
272
273
  - test/model_reflections_test.rb
273
274
  - test/model_validations_test.rb
274
275
  - test/nested_form_test.rb
275
276
  - test/rails/integration_test.rb
276
277
  - test/read_only_test.rb
278
+ - test/readable_test.rb
277
279
  - test/reform_test.rb
278
280
  - test/representer_test.rb
279
281
  - test/save_test.rb
@@ -285,6 +287,8 @@ files:
285
287
  - test/test_helper.rb
286
288
  - test/twin_test.rb
287
289
  - test/validate_test.rb
290
+ - test/virtual_test.rb
291
+ - test/writeable_test.rb
288
292
  homepage: https://github.com/apotonick/reform
289
293
  licenses:
290
294
  - MIT
@@ -300,9 +304,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
300
304
  version: '0'
301
305
  required_rubygems_version: !ruby/object:Gem::Requirement
302
306
  requirements:
303
- - - ">"
307
+ - - ">="
304
308
  - !ruby/object:Gem::Version
305
- version: 1.3.1
309
+ version: '0'
306
310
  requirements: []
307
311
  rubyforge_project:
308
312
  rubygems_version: 2.2.2
@@ -313,7 +317,7 @@ summary: Decouples your models from form by giving you form objects with validat
313
317
  test_files:
314
318
  - test/active_model_test.rb
315
319
  - test/active_record_test.rb
316
- - test/as_test.rb
320
+ - test/benchmarking.rb
317
321
  - test/builder_test.rb
318
322
  - test/changed_test.rb
319
323
  - test/coercion_test.rb
@@ -351,12 +355,14 @@ test_files:
351
355
  - test/form_builder_test.rb
352
356
  - test/form_composition_test.rb
353
357
  - test/form_test.rb
358
+ - test/from_test.rb
354
359
  - test/inherit_test.rb
355
360
  - test/model_reflections_test.rb
356
361
  - test/model_validations_test.rb
357
362
  - test/nested_form_test.rb
358
363
  - test/rails/integration_test.rb
359
364
  - test/read_only_test.rb
365
+ - test/readable_test.rb
360
366
  - test/reform_test.rb
361
367
  - test/representer_test.rb
362
368
  - test/save_test.rb
@@ -368,3 +374,5 @@ test_files:
368
374
  - test/test_helper.rb
369
375
  - test/twin_test.rb
370
376
  - test/validate_test.rb
377
+ - test/virtual_test.rb
378
+ - test/writeable_test.rb
data/test/as_test.rb DELETED
@@ -1,75 +0,0 @@
1
- require 'test_helper'
2
-
3
- class AsTest < BaseTest
4
- class AlbumForm < Reform::Form
5
- property :name, :as => :title
6
-
7
- property :single, :as => :hit do
8
- property :title
9
- end
10
-
11
- collection :tracks, :as => :songs do
12
- property :name, :as => :title
13
- end
14
-
15
- property :band do
16
- property :company, :as => :label do
17
- property :business, :as => :name
18
- end
19
- end
20
- end
21
-
22
- let (:song2) { Song.new("Roxanne") }
23
-
24
- let (:params) {
25
- {
26
- "name" => "Best Of The Police",
27
- "single" => {"title" => "So Lonely"},
28
- "tracks" => [{"name" => "Message In A Bottle"}, {"name" => "Roxanne"}]
29
- }
30
- }
31
-
32
- subject { AlbumForm.new(Album.new("Best Of", hit, [Song.new("Fallout"), song2])) }
33
-
34
- it { subject.name.must_equal "Best Of" }
35
- it { subject.single.title.must_equal "Roxanne" }
36
- it { subject.tracks[0].name.must_equal "Fallout" }
37
- it { subject.tracks[1].name.must_equal "Roxanne" }
38
-
39
-
40
- describe "#validate" do
41
-
42
-
43
- before { subject.validate(params) }
44
-
45
- it { subject.name.must_equal "Best Of The Police" }
46
- it { subject.single.title.must_equal "So Lonely" }
47
- it { subject.tracks[0].name.must_equal "Message In A Bottle" }
48
- it { subject.tracks[1].name.must_equal "Roxanne" }
49
- end
50
-
51
-
52
- describe "#sync" do
53
- before {
54
- subject.tracks[1].name = "Livin' Ain't No Crime"
55
- subject.sync
56
- }
57
-
58
- it { song2.title.must_equal "Livin' Ain't No Crime" }
59
- end
60
-
61
-
62
- describe "#save (nested hash)" do
63
- before { subject.validate(params) }
64
-
65
- it do
66
- hash = nil
67
-
68
- subject.save do |nested_hash|
69
- hash = nested_hash
70
- end
71
-
72
- hash.must_equal({"title"=>"Best Of The Police", "hit"=>{"title"=>"So Lonely"}, "songs"=>[{"title"=>"Message In A Bottle"}, {"title"=>"Roxanne"}]})
73
- end
74
- end
75
- end