freeform 1.0.3 → 1.0.4
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.
- checksums.yaml +8 -8
- data/Gemfile.lock +2 -2
- data/lib/freeform/builder/builder_mixin.rb +6 -6
- data/lib/freeform/version.rb +1 -1
- data/spec/acceptance_spec.rb +39 -1
- data/spec/builder/builder_spec.rb +11 -11
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +13493 -0
- data/spec/javascript_spec.rb +2 -2
- data/spec/persistence_spec.rb +77 -40
- metadata +1 -3
- data/vendor/assets/javascripts/jquery_nested_form.js +0 -0
- data/vendor/assets/javascripts/prototype_nested_form.js +0 -0
data/spec/javascript_spec.rb
CHANGED
|
@@ -4,7 +4,7 @@ describe 'JavaScript Behavior', :js => true do
|
|
|
4
4
|
include Capybara::DSL
|
|
5
5
|
|
|
6
6
|
[:jquery, :prototype].each do |js_framework|
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
url = case js_framework
|
|
9
9
|
when :jquery then '/projects/new'
|
|
10
10
|
when :prototype then '/projects/new?type=prototype'
|
|
@@ -57,4 +57,4 @@ describe 'JavaScript Behavior', :js => true do
|
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
|
-
end
|
|
60
|
+
end
|
data/spec/persistence_spec.rb
CHANGED
|
@@ -7,7 +7,7 @@ describe FreeForm::Form do
|
|
|
7
7
|
form_model :task
|
|
8
8
|
validate_models
|
|
9
9
|
allow_destroy_on_save
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
property :name, :on => :task
|
|
12
12
|
property :start_date, :on => :task
|
|
13
13
|
property :end_date, :on => :task
|
|
@@ -23,18 +23,18 @@ describe FreeForm::Form do
|
|
|
23
23
|
klass = Class.new(FreeForm::Form) do
|
|
24
24
|
form_input_key :company
|
|
25
25
|
form_models :company
|
|
26
|
-
child_model :project do
|
|
26
|
+
child_model :project do
|
|
27
27
|
company.project.present? ? company.project : company.build_project
|
|
28
28
|
end
|
|
29
29
|
validate_models
|
|
30
30
|
allow_destroy_on_save
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
property :name, :on => :company, :as => :company_name
|
|
33
33
|
property :name, :on => :project, :as => :project_name
|
|
34
34
|
property :due_date, :on => :project
|
|
35
35
|
|
|
36
36
|
has_many :tasks, :class => Module::TaskForm, :default_initializer => :default_task_initializer
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
def default_task_initializer
|
|
39
39
|
{ :task => project.tasks.build }
|
|
40
40
|
end
|
|
@@ -45,12 +45,12 @@ describe FreeForm::Form do
|
|
|
45
45
|
$VERBOSE = v
|
|
46
46
|
klass
|
|
47
47
|
end
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
let(:company) { Company.create!(:name => "Demo Corporation") }
|
|
50
50
|
let(:project) { Project.create!(:company => company, :name => "Widget", :due_date => Date.new(2014, 1, 1)) }
|
|
51
51
|
let(:task_1) { Task.create!(:project => project, :name => "Task 1", :start_date => Date.new(2014, 2, 2), :end_date => Date.new(2014, 3, 3)) }
|
|
52
52
|
let(:task_2) { Task.create!(:project => project, :name => "Task 2", :start_date => Date.new(2014, 9, 1), :end_date => Date.new(2014, 10, 1)) }
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
let(:form) do
|
|
55
55
|
f = form_class.new( :company => company )
|
|
56
56
|
company.project.tasks.each do |task|
|
|
@@ -58,14 +58,14 @@ describe FreeForm::Form do
|
|
|
58
58
|
end
|
|
59
59
|
f
|
|
60
60
|
end
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
before(:each) do
|
|
63
63
|
company.reload
|
|
64
64
|
project.reload
|
|
65
65
|
task_1.reload
|
|
66
66
|
task_2.reload
|
|
67
67
|
end
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
describe "form initialization", :initialization => true do
|
|
70
70
|
it "initializes with Company model" do
|
|
71
71
|
form.company.should eq(company)
|
|
@@ -129,11 +129,11 @@ describe FreeForm::Form do
|
|
|
129
129
|
}
|
|
130
130
|
} }
|
|
131
131
|
end
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
before(:each) do
|
|
134
134
|
form.fill(attributes)
|
|
135
135
|
end
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
it "assigns company name" do
|
|
138
138
|
form.company_name.should eq("dummycorp")
|
|
139
139
|
form.company.name.should eq("dummycorp")
|
|
@@ -193,12 +193,12 @@ describe FreeForm::Form do
|
|
|
193
193
|
}
|
|
194
194
|
} }
|
|
195
195
|
end
|
|
196
|
-
|
|
196
|
+
|
|
197
197
|
before(:each) do
|
|
198
198
|
form.fill(attributes)
|
|
199
199
|
form.valid?
|
|
200
200
|
end
|
|
201
|
-
|
|
201
|
+
|
|
202
202
|
it "should be invalid" do
|
|
203
203
|
form.should_not be_valid
|
|
204
204
|
end
|
|
@@ -234,12 +234,12 @@ describe FreeForm::Form do
|
|
|
234
234
|
}
|
|
235
235
|
} }
|
|
236
236
|
end
|
|
237
|
-
|
|
237
|
+
|
|
238
238
|
before(:each) do
|
|
239
239
|
form.fill(attributes)
|
|
240
240
|
form.valid?
|
|
241
241
|
end
|
|
242
|
-
|
|
242
|
+
|
|
243
243
|
it "should be invalid" do
|
|
244
244
|
form.should_not be_valid
|
|
245
245
|
end
|
|
@@ -274,11 +274,11 @@ describe FreeForm::Form do
|
|
|
274
274
|
}
|
|
275
275
|
} }
|
|
276
276
|
end
|
|
277
|
-
|
|
277
|
+
|
|
278
278
|
before(:each) do
|
|
279
279
|
form.fill(attributes)
|
|
280
280
|
end
|
|
281
|
-
|
|
281
|
+
|
|
282
282
|
it "should be valid" do
|
|
283
283
|
form.should be_valid
|
|
284
284
|
end
|
|
@@ -308,17 +308,54 @@ describe FreeForm::Form do
|
|
|
308
308
|
}
|
|
309
309
|
} }
|
|
310
310
|
end
|
|
311
|
-
|
|
311
|
+
|
|
312
312
|
before(:each) do
|
|
313
313
|
form.fill(attributes)
|
|
314
314
|
end
|
|
315
|
-
|
|
315
|
+
|
|
316
316
|
it "should return false on 'save'" do
|
|
317
317
|
form.save.should be_false
|
|
318
318
|
end
|
|
319
319
|
|
|
320
320
|
it "should raise error on 'save!'" do
|
|
321
|
-
expect{ form.save
|
|
321
|
+
expect{ form.save! }.to raise_error(FreeForm::FormInvalid)
|
|
322
|
+
end
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
context "with invalid, marked for destruction attributes", :failing => true do
|
|
326
|
+
let(:attributes) do {
|
|
327
|
+
:company_name => "dummycorp",
|
|
328
|
+
:project_name => "my_project",
|
|
329
|
+
"due_date(1i)" => "2014",
|
|
330
|
+
"due_date(2i)" => "10",
|
|
331
|
+
"due_date(3i)" => "30",
|
|
332
|
+
:tasks_attributes => {
|
|
333
|
+
"0" => {
|
|
334
|
+
:name => "task_1",
|
|
335
|
+
"start_date(1i)" => "2012",
|
|
336
|
+
"start_date(2i)" => "1",
|
|
337
|
+
"start_date(3i)" => "2",
|
|
338
|
+
},
|
|
339
|
+
"1" => {
|
|
340
|
+
:name => "task_2",
|
|
341
|
+
"end_date(1i)" => "2011",
|
|
342
|
+
"end_date(2i)" => "12",
|
|
343
|
+
"end_date(3i)" => "15",
|
|
344
|
+
:_destroy => "1"
|
|
345
|
+
}
|
|
346
|
+
} }
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
before(:each) do
|
|
350
|
+
form.fill(attributes)
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
it "should return true on 'save'" do
|
|
354
|
+
form.save.should be_true
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
it "should not raise error on 'save!'" do
|
|
358
|
+
expect{ form.save! }.to_not raise_error
|
|
322
359
|
end
|
|
323
360
|
end
|
|
324
361
|
|
|
@@ -347,11 +384,11 @@ describe FreeForm::Form do
|
|
|
347
384
|
}
|
|
348
385
|
} }
|
|
349
386
|
end
|
|
350
|
-
|
|
387
|
+
|
|
351
388
|
before(:each) do
|
|
352
389
|
form.fill(attributes)
|
|
353
390
|
end
|
|
354
|
-
|
|
391
|
+
|
|
355
392
|
describe "save", :save => true do
|
|
356
393
|
describe "without destroy" do
|
|
357
394
|
it "should return true on 'save', and call save on other models" do
|
|
@@ -361,7 +398,7 @@ describe FreeForm::Form do
|
|
|
361
398
|
form.tasks.last.task.should_receive(:save).and_return(true)
|
|
362
399
|
form.save
|
|
363
400
|
end
|
|
364
|
-
|
|
401
|
+
|
|
365
402
|
describe "value assignment and persistence" do
|
|
366
403
|
before(:each) { form.save }
|
|
367
404
|
|
|
@@ -369,7 +406,7 @@ describe FreeForm::Form do
|
|
|
369
406
|
company.reload
|
|
370
407
|
company.name.should eq("dummycorp")
|
|
371
408
|
end
|
|
372
|
-
|
|
409
|
+
|
|
373
410
|
it "assigns project values" do
|
|
374
411
|
project.reload
|
|
375
412
|
project.name.should eq("railsapp")
|
|
@@ -391,8 +428,8 @@ describe FreeForm::Form do
|
|
|
391
428
|
end
|
|
392
429
|
end
|
|
393
430
|
end
|
|
394
|
-
|
|
395
|
-
describe "with destroy" do
|
|
431
|
+
|
|
432
|
+
describe "with destroy" do
|
|
396
433
|
it "destroys models on save if set" do
|
|
397
434
|
form._destroy = true
|
|
398
435
|
form.company.should_receive(:destroy).and_return(true)
|
|
@@ -401,7 +438,7 @@ describe FreeForm::Form do
|
|
|
401
438
|
form.tasks.last.task.should_receive(:save).and_return(true)
|
|
402
439
|
form.save
|
|
403
440
|
end
|
|
404
|
-
|
|
441
|
+
|
|
405
442
|
it "destroys models on save if set through attribute" do
|
|
406
443
|
form.fill({:_destroy => "1"})
|
|
407
444
|
form.company.should_receive(:destroy).and_return(true)
|
|
@@ -418,7 +455,7 @@ describe FreeForm::Form do
|
|
|
418
455
|
it "destroys company" do
|
|
419
456
|
expect { company.reload }.to raise_error
|
|
420
457
|
end
|
|
421
|
-
|
|
458
|
+
|
|
422
459
|
it "destroys project" do
|
|
423
460
|
expect { project.reload }.to raise_error
|
|
424
461
|
end
|
|
@@ -438,8 +475,8 @@ describe FreeForm::Form do
|
|
|
438
475
|
end
|
|
439
476
|
end
|
|
440
477
|
end
|
|
441
|
-
|
|
442
|
-
describe "with nested destroy" do
|
|
478
|
+
|
|
479
|
+
describe "with nested destroy" do
|
|
443
480
|
before(:each) { form.tasks.first._destroy = true }
|
|
444
481
|
|
|
445
482
|
it "destroys nested models on save if set" do
|
|
@@ -449,7 +486,7 @@ describe FreeForm::Form do
|
|
|
449
486
|
form.tasks.last.task.should_receive(:save).and_return(true)
|
|
450
487
|
form.save
|
|
451
488
|
end
|
|
452
|
-
|
|
489
|
+
|
|
453
490
|
describe "value assignment and persistence" do
|
|
454
491
|
before(:each) { form.save }
|
|
455
492
|
|
|
@@ -457,7 +494,7 @@ describe FreeForm::Form do
|
|
|
457
494
|
company.reload
|
|
458
495
|
company.name.should eq("dummycorp")
|
|
459
496
|
end
|
|
460
|
-
|
|
497
|
+
|
|
461
498
|
it "assigns project values" do
|
|
462
499
|
project.reload
|
|
463
500
|
project.name.should eq("railsapp")
|
|
@@ -477,7 +514,7 @@ describe FreeForm::Form do
|
|
|
477
514
|
end
|
|
478
515
|
end
|
|
479
516
|
end
|
|
480
|
-
|
|
517
|
+
|
|
481
518
|
describe "save!", :save! => true do
|
|
482
519
|
describe "without destroy" do
|
|
483
520
|
it "should return true on 'save!', and call save! on other models" do
|
|
@@ -495,7 +532,7 @@ describe FreeForm::Form do
|
|
|
495
532
|
company.reload
|
|
496
533
|
company.name.should eq("dummycorp")
|
|
497
534
|
end
|
|
498
|
-
|
|
535
|
+
|
|
499
536
|
it "assigns project values" do
|
|
500
537
|
project.reload
|
|
501
538
|
project.name.should eq("railsapp")
|
|
@@ -517,8 +554,8 @@ describe FreeForm::Form do
|
|
|
517
554
|
end
|
|
518
555
|
end
|
|
519
556
|
end
|
|
520
|
-
|
|
521
|
-
describe "with destroy" do
|
|
557
|
+
|
|
558
|
+
describe "with destroy" do
|
|
522
559
|
it "destroys models on save! if set" do
|
|
523
560
|
form._destroy = true
|
|
524
561
|
form.company.should_receive(:destroy).and_return(true)
|
|
@@ -527,7 +564,7 @@ describe FreeForm::Form do
|
|
|
527
564
|
form.tasks.last.task.should_receive(:save!).and_return(true)
|
|
528
565
|
form.save!
|
|
529
566
|
end
|
|
530
|
-
|
|
567
|
+
|
|
531
568
|
it "destroys models on save! if set" do
|
|
532
569
|
form.fill({:_destroy => "1"})
|
|
533
570
|
form.company.should_receive(:destroy).and_return(true)
|
|
@@ -544,7 +581,7 @@ describe FreeForm::Form do
|
|
|
544
581
|
it "destroys company" do
|
|
545
582
|
expect { company.reload }.to raise_error
|
|
546
583
|
end
|
|
547
|
-
|
|
584
|
+
|
|
548
585
|
it "destroys project" do
|
|
549
586
|
expect { project.reload }.to raise_error
|
|
550
587
|
end
|
|
@@ -564,7 +601,7 @@ describe FreeForm::Form do
|
|
|
564
601
|
end
|
|
565
602
|
end
|
|
566
603
|
end
|
|
567
|
-
|
|
604
|
+
|
|
568
605
|
describe "with nested destroy" do
|
|
569
606
|
it "destroys nested models on save! if set" do
|
|
570
607
|
form.tasks.last._destroy = true
|
|
@@ -583,7 +620,7 @@ describe FreeForm::Form do
|
|
|
583
620
|
company.reload
|
|
584
621
|
company.name.should eq("dummycorp")
|
|
585
622
|
end
|
|
586
|
-
|
|
623
|
+
|
|
587
624
|
it "assigns project values" do
|
|
588
625
|
project.reload
|
|
589
626
|
project.name.should eq("railsapp")
|
|
@@ -601,7 +638,7 @@ describe FreeForm::Form do
|
|
|
601
638
|
task_2.end_date.should eq(Date.new(2011, 12, 15))
|
|
602
639
|
end
|
|
603
640
|
end
|
|
604
|
-
end
|
|
641
|
+
end
|
|
605
642
|
end
|
|
606
643
|
end
|
|
607
644
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: freeform
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- brycesenz
|
|
@@ -281,9 +281,7 @@ files:
|
|
|
281
281
|
- spec/persistence_spec.rb
|
|
282
282
|
- spec/spec_helper.rb
|
|
283
283
|
- vendor/assets/javascripts/jquery_freeform.js
|
|
284
|
-
- vendor/assets/javascripts/jquery_nested_form.js
|
|
285
284
|
- vendor/assets/javascripts/prototype_freeform.js
|
|
286
|
-
- vendor/assets/javascripts/prototype_nested_form.js
|
|
287
285
|
homepage: https://github.com/brycesenz/freeform
|
|
288
286
|
licenses:
|
|
289
287
|
- MIT
|
|
File without changes
|
|
File without changes
|