freeform 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -17
- data/Gemfile +1 -1
- data/Gemfile.lock +150 -0
- data/MIT-LICENSE +20 -0
- data/README.md +31 -43
- data/Rakefile +32 -1
- data/freeform.gemspec +22 -15
- data/lib/freeform/builder/builder_mixin.rb +111 -0
- data/lib/freeform/builder/builders.rb +32 -0
- data/lib/freeform/builder/engine.rb +14 -0
- data/lib/freeform/builder/view_helper.rb +56 -0
- data/lib/freeform/form/form_input_key.rb +1 -1
- data/lib/freeform/form/nested.rb +17 -55
- data/lib/freeform/form/property.rb +82 -42
- data/lib/freeform/form/validation.rb +38 -11
- data/lib/freeform/form.rb +24 -27
- data/lib/freeform/version.rb +1 -1
- data/lib/freeform.rb +4 -0
- data/lib/generators/freeform/install_generator.rb +17 -0
- data/lib/tasks/freeform_tasks.rake +4 -0
- data/spec/acceptance_spec.rb +261 -155
- data/spec/builder/builder_spec.rb +215 -0
- data/spec/builder/view_helper_spec.rb +97 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +5 -0
- data/spec/dummy/app/assets/javascripts/jquery.js +9404 -0
- data/spec/dummy/app/assets/javascripts/jquery_events_test.js +19 -0
- data/spec/dummy/app/assets/javascripts/projects.js +2 -0
- data/spec/dummy/app/assets/javascripts/prototype.js +6082 -0
- data/spec/dummy/app/assets/javascripts/prototype_events_test.js +20 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/assets/stylesheets/companies.css +4 -0
- data/spec/dummy/app/assets/stylesheets/projects.css +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/companies_controller.rb +5 -0
- data/spec/dummy/app/controllers/projects_controller.rb +11 -0
- data/spec/dummy/app/forms/milestone_form.rb +4 -0
- data/spec/dummy/app/forms/project_form.rb +11 -0
- data/spec/dummy/app/forms/task_form.rb +10 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/company.rb +5 -0
- data/spec/dummy/app/models/milestone.rb +6 -0
- data/spec/dummy/app/models/project.rb +9 -0
- data/spec/dummy/app/models/project_task.rb +3 -0
- data/spec/dummy/app/models/task.rb +7 -0
- data/spec/dummy/app/views/companies/new.html.erb +16 -0
- data/spec/dummy/app/views/layouts/application.html.erb +19 -0
- data/spec/dummy/app/views/projects/new.html.erb +13 -0
- data/spec/dummy/app/views/projects/without_intermediate_inputs.html.erb +11 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +35 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +13 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20110710143903_initial_tables.rb +38 -0
- data/spec/dummy/db/schema.rb +43 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +39736 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/C54/850/sprockets%2Fd484f47085686f151320ff7248bb5105 +0 -0
- data/spec/dummy/tmp/cache/assets/C76/160/sprockets%2F49c594d143212b346d11f1ecf9358103 +0 -0
- data/spec/dummy/tmp/cache/assets/C99/4D0/sprockets%2F5e30a6b911437f1428dc32c3ae182123 +0 -0
- data/spec/dummy/tmp/cache/assets/C99/7D0/sprockets%2F79513e6956e0ee8624976e041fd5636d +0 -0
- data/spec/dummy/tmp/cache/assets/CAA/C90/sprockets%2F1e6c8ee1258009385ccf5b84015424b3 +0 -0
- data/spec/dummy/tmp/cache/assets/CB2/CB0/sprockets%2F11cc8d161d71a716dd36f16849d90870 +0 -0
- data/spec/dummy/tmp/cache/assets/CB7/7F0/sprockets%2Fac97b043470f6fcc925c352f16956643 +0 -0
- data/spec/dummy/tmp/cache/assets/CBA/680/sprockets%2F912d84e091e5f2190b1ab7926de19679 +0 -0
- data/spec/dummy/tmp/cache/assets/CC7/430/sprockets%2F48e99a3e16ba3e65749e009d82546f94 +0 -0
- data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/CDB/8A0/sprockets%2Faed2a2575c376263c26e93b56b57051d +0 -0
- data/spec/dummy/tmp/cache/assets/CF1/E80/sprockets%2F7735295e1e3085f2e1dc29d59a45e8e6 +0 -0
- data/spec/dummy/tmp/cache/assets/D0F/E60/sprockets%2F1123d9a479fdf5c2b8415087e2a43ec6 +0 -0
- data/spec/dummy/tmp/cache/assets/D1F/A10/sprockets%2F60317e62cb324bfd9987e8da9636fd06 +0 -0
- data/spec/dummy/tmp/cache/assets/D25/E20/sprockets%2F29ba1a4a2b611731334f54abb9e5b5d1 +0 -0
- data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/D35/760/sprockets%2F49e26620c5c743ac4cdab7703f54db06 +0 -0
- data/spec/dummy/tmp/cache/assets/D49/870/sprockets%2F90896142645585acc8baf56ad57e3afb +0 -0
- data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/D62/F00/sprockets%2F6ac03a007f26b1c18ed3d53498ad3eb8 +0 -0
- data/spec/dummy/tmp/cache/assets/D79/BC0/sprockets%2F85a1db977361cc5130fcefb4637ff67e +0 -0
- data/spec/dummy/tmp/cache/assets/D87/1F0/sprockets%2F61c9ceafb877fb740c67416ff6f782a9 +0 -0
- data/spec/dummy/tmp/cache/assets/DA8/900/sprockets%2Fde7a2b3987b89b9d9afb268ce4204a4a +0 -0
- data/spec/dummy/tmp/cache/assets/DAD/4F0/sprockets%2F765acd1bf68dc90f7d3e61da78b1e659 +0 -0
- data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/E03/3F0/sprockets%2F82b37ae9eccec44c1ef44cfdd07d8534 +0 -0
- data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/E0A/CA0/sprockets%2F7fe72ac1c0db1a7e8e7f59cf25e8a39e +0 -0
- data/spec/dummy/tmp/cache/assets/E20/9B0/sprockets%2F2fa6cd86b1af7bda41f5b7921cdadf10 +0 -0
- data/spec/dummy/tmp/cache/assets/E3A/A60/sprockets%2F7c72c96cfc66454caf5fc8ca0fedd4f3 +0 -0
- data/spec/dummy/tmp/cache/assets/E54/400/sprockets%2Fd0cbc16cc37efcf9dc41f242b5dbbf81 +0 -0
- data/spec/dummy/tmp/cache/assets/EB7/AB0/sprockets%2F801d29a5debdbfbfb4eef14d70d9bcdb +0 -0
- data/spec/dummy/tmp/cache/assets/F48/5E0/sprockets%2F26cd6ffcffbebbe2fd6cd1a8f0c2debc +0 -0
- data/spec/form/nested_spec.rb +75 -61
- data/spec/form/property_spec.rb +167 -14
- data/spec/form/validation_spec.rb +46 -23
- data/spec/javascript_spec.rb +60 -0
- data/spec/persistence_spec.rb +608 -0
- data/spec/spec_helper.rb +18 -2
- data/vendor/assets/javascripts/jquery_freeform.js +120 -0
- data/vendor/assets/javascripts/jquery_nested_form.js +0 -0
- data/vendor/assets/javascripts/prototype_freeform.js +69 -0
- data/vendor/assets/javascripts/prototype_nested_form.js +0 -0
- metadata +341 -3
@@ -0,0 +1,215 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
[FreeForm::Builder, FreeForm::SimpleBuilder, defined?(FreeForm::FormtasticBuilder) ? FreeForm::FormtasticBuilder : nil].compact.each do |builder|
|
4
|
+
describe builder do
|
5
|
+
let!(:milestone_form_class) do
|
6
|
+
klass = Class.new(FreeForm::Form) do
|
7
|
+
form_input_key :milestone
|
8
|
+
form_models :milestone
|
9
|
+
allow_destroy_on_save
|
10
|
+
|
11
|
+
property :name, :on => :milestone
|
12
|
+
end
|
13
|
+
# This wrapper just avoids CONST warnings
|
14
|
+
v, $VERBOSE = $VERBOSE, nil
|
15
|
+
Module.const_set("MilestoneForm", klass)
|
16
|
+
$VERBOSE = v
|
17
|
+
klass
|
18
|
+
end
|
19
|
+
|
20
|
+
let!(:task_form_class) do
|
21
|
+
klass = Class.new(FreeForm::Form) do
|
22
|
+
form_input_key :task
|
23
|
+
form_models :task
|
24
|
+
allow_destroy_on_save
|
25
|
+
|
26
|
+
property :name, :on => :task
|
27
|
+
|
28
|
+
has_many :milestones, :class => Module::MilestoneForm, :default_initializer => :milestone_initializer
|
29
|
+
|
30
|
+
def milestone_initializer
|
31
|
+
{:milestone => Milestone.new}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
# This wrapper just avoids CONST warnings
|
35
|
+
v, $VERBOSE = $VERBOSE, nil
|
36
|
+
Module.const_set("TaskForm", klass)
|
37
|
+
$VERBOSE = v
|
38
|
+
klass
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:form_class) do
|
42
|
+
klass = Class.new(FreeForm::Form) do
|
43
|
+
form_input_key :project
|
44
|
+
form_models :project
|
45
|
+
allow_destroy_on_save
|
46
|
+
|
47
|
+
property :name, :on => :project
|
48
|
+
|
49
|
+
has_many :tasks, :class => Module::TaskForm, :default_initializer => :task_initializer
|
50
|
+
|
51
|
+
def task_initializer
|
52
|
+
{:task => Task.new}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
# This wrapper just avoids CONST warnings
|
56
|
+
v, $VERBOSE = $VERBOSE, nil
|
57
|
+
Module.const_set("ViewForm", klass)
|
58
|
+
$VERBOSE = v
|
59
|
+
klass
|
60
|
+
end
|
61
|
+
|
62
|
+
let(:form) { form_class.new(:project => Project.new) }
|
63
|
+
|
64
|
+
let(:template) do
|
65
|
+
template = ActionView::Base.new
|
66
|
+
template.output_buffer = ""
|
67
|
+
template
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with no options", :no_options => true do
|
71
|
+
subject do
|
72
|
+
builder.new(:item, form, template, {}, proc {})
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#link_to_add', :link_to_add => true do
|
76
|
+
it "behaves similar to a Rails link_to" do
|
77
|
+
subject.link_to_add("Add", :tasks).should eq('<a href="javascript:void(0)" class="add_nested_form" data-association="tasks" data-blueprint-id="tasks_fields_blueprint">Add</a>')
|
78
|
+
subject.link_to_add("Add", :tasks, :class => "foo", :href => "url").should eq('<a href="url" class="foo add_nested_form" data-association="tasks" data-blueprint-id="tasks_fields_blueprint">Add</a>')
|
79
|
+
subject.link_to_add(:tasks) { "Add" }.should eq('<a href="javascript:void(0)" class="add_nested_form" data-association="tasks" data-blueprint-id="tasks_fields_blueprint">Add</a>')
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'raises ArgumentError when missing association is provided' do
|
83
|
+
expect {
|
84
|
+
subject.link_to_add('Add', :bugs)
|
85
|
+
}.to raise_error(ArgumentError)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'raises ArgumentError when accepts_nested_attributes_for is missing' do
|
89
|
+
expect {
|
90
|
+
subject.link_to_add('Add', :not_nested_tasks)
|
91
|
+
}.to raise_error(ArgumentError)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#link_to_remove', :link_to_remove => true do
|
96
|
+
it "behaves similar to a Rails link_to" do
|
97
|
+
subject.link_to_remove("Remove").should eq('<input id="item__destroy" name="item[_destroy]" type="hidden" value="0" /><a href="javascript:void(0)" class="remove_nested_form">Remove</a>')
|
98
|
+
subject.link_to_remove("Remove", :class => "foo", :href => "url").should eq('<input id="item__destroy" name="item[_destroy]" type="hidden" value="0" /><a href="url" class="foo remove_nested_form">Remove</a>')
|
99
|
+
subject.link_to_remove { "Remove" }.should eq('<input id="item__destroy" name="item[_destroy]" type="hidden" value="0" /><a href="javascript:void(0)" class="remove_nested_form">Remove</a>')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'has data-association attribute' do
|
103
|
+
form.build_task
|
104
|
+
subject.fields_for(:tasks, :builder => builder) do |tf|
|
105
|
+
tf.link_to_remove 'Remove'
|
106
|
+
end.should match '<a.+data-association="tasks">Remove</a>'
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'when there is more than one nested level' do
|
110
|
+
it 'properly detects association name' do
|
111
|
+
task = form.build_task
|
112
|
+
task.build_milestone
|
113
|
+
subject.fields_for(:tasks, :builder => builder) do |tf|
|
114
|
+
tf.fields_for(:milestones, :builder => builder) do |mf|
|
115
|
+
mf.link_to_remove 'Remove'
|
116
|
+
end
|
117
|
+
end.should match '<a.+data-association="milestones">Remove</a>'
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe '#fields_for' do
|
123
|
+
it "wraps nested fields each in a div with class" do
|
124
|
+
2.times { form.build_task }
|
125
|
+
|
126
|
+
fields = if subject.is_a?(FreeForm::SimpleBuilder)
|
127
|
+
subject.simple_fields_for(:tasks) { "Task" }
|
128
|
+
else
|
129
|
+
subject.fields_for(:tasks) { "Task" }
|
130
|
+
end
|
131
|
+
|
132
|
+
fields.should == '<div class="fields">Task</div><div class="fields">Task</div>'
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
it "wraps nested fields marked for destruction with an additional class" do
|
137
|
+
task = form.build_task
|
138
|
+
task.mark_for_destruction
|
139
|
+
fields = subject.fields_for(:tasks) { 'Task' }
|
140
|
+
fields.should eq('<div class="fields marked_for_destruction">Task</div>')
|
141
|
+
end
|
142
|
+
|
143
|
+
it "puts blueprint into data-blueprint attribute" do
|
144
|
+
task = form.build_task
|
145
|
+
task.mark_for_destruction
|
146
|
+
subject.fields_for(:tasks) { 'Task' }
|
147
|
+
subject.link_to_add('Add', :tasks)
|
148
|
+
output = template.send(:after_freeform_callbacks)
|
149
|
+
expected = ERB::Util.html_escape '<div class="fields">Task</div>'
|
150
|
+
output.should match(/div.+data-blueprint="#{expected}"/)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "adds parent association name to the blueprint div id" do
|
154
|
+
task = form.build_task
|
155
|
+
task.build_milestone
|
156
|
+
subject.fields_for(:tasks, :builder => builder) do |tf|
|
157
|
+
tf.fields_for(:milestones, :builder => builder) { 'Milestone' }
|
158
|
+
tf.link_to_add('Add', :milestones)
|
159
|
+
end
|
160
|
+
output = template.send(:after_freeform_callbacks)
|
161
|
+
output.should match(/div.+id="tasks_milestones_fields_blueprint"/)
|
162
|
+
end
|
163
|
+
|
164
|
+
it "doesn't render wrapper div" do
|
165
|
+
task = form.build_task
|
166
|
+
fields = subject.fields_for(:tasks, :wrapper => false) { 'Task' }
|
167
|
+
|
168
|
+
fields.should eq('Task')
|
169
|
+
|
170
|
+
subject.link_to_add 'Add', :tasks
|
171
|
+
output = template.send(:after_freeform_callbacks)
|
172
|
+
|
173
|
+
output.should match(/div.+data-blueprint="Task"/)
|
174
|
+
end
|
175
|
+
|
176
|
+
it "doesn't render wrapper div when collection is passed" do
|
177
|
+
task = form.build_task
|
178
|
+
fields = subject.fields_for(:tasks, form.tasks, :wrapper => false) { 'Task' }
|
179
|
+
|
180
|
+
fields.should eq('Task')
|
181
|
+
|
182
|
+
subject.link_to_add 'Add', :tasks
|
183
|
+
output = template.send(:after_freeform_callbacks)
|
184
|
+
|
185
|
+
output.should match(/div.+data-blueprint="Task"/)
|
186
|
+
end
|
187
|
+
|
188
|
+
it "doesn't render wrapper with nested_wrapper option" do
|
189
|
+
task = form.build_task
|
190
|
+
fields = subject.fields_for(:tasks, :nested_wrapper => false) { 'Task' }
|
191
|
+
|
192
|
+
fields.should eq('Task')
|
193
|
+
|
194
|
+
subject.link_to_add 'Add', :tasks
|
195
|
+
output = template.send(:after_freeform_callbacks)
|
196
|
+
|
197
|
+
output.should match(/div.+data-blueprint="Task"/)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
context "with options", :with_options => true do
|
202
|
+
subject { builder.new(:item, form, template, {}, proc {}) }
|
203
|
+
|
204
|
+
context "when model_object given" do
|
205
|
+
it "should use it instead of new generated" do
|
206
|
+
subject.fields_for(:tasks) {|f| f.object.name }
|
207
|
+
subject.link_to_add("Add", :tasks, :model_object => Task.new(:name => 'for check'))
|
208
|
+
output = template.send(:after_freeform_callbacks)
|
209
|
+
expected = ERB::Util.html_escape '<div class="fields">for check</div>'
|
210
|
+
output.should match(/div.+data-blueprint="#{expected}"/)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe FreeForm::ViewHelper do
|
4
|
+
include RSpec::Rails::HelperExampleGroup
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
_routes.draw do
|
8
|
+
resources :projects
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let!(:task_form_class) do
|
13
|
+
klass = Class.new(FreeForm::Form) do
|
14
|
+
form_input_key :task
|
15
|
+
form_model :task
|
16
|
+
allow_destroy_on_save
|
17
|
+
|
18
|
+
property :name, :on => :task
|
19
|
+
end
|
20
|
+
# This wrapper just avoids CONST warnings
|
21
|
+
v, $VERBOSE = $VERBOSE, nil
|
22
|
+
Module.const_set("TaskForm", klass)
|
23
|
+
$VERBOSE = v
|
24
|
+
klass
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:form_class) do
|
28
|
+
klass = Class.new(FreeForm::Form) do
|
29
|
+
form_input_key :project
|
30
|
+
form_models :project
|
31
|
+
allow_destroy_on_save
|
32
|
+
|
33
|
+
property :name, :on => :project
|
34
|
+
|
35
|
+
has_many :tasks, :class => Module::TaskForm, :default_initializer => :task_initializer
|
36
|
+
|
37
|
+
def task_initializer
|
38
|
+
{:task => Task.new}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
# This wrapper just avoids CONST warnings
|
42
|
+
v, $VERBOSE = $VERBOSE, nil
|
43
|
+
Module.const_set("ViewForm", klass)
|
44
|
+
$VERBOSE = v
|
45
|
+
klass
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:project) { Project.new }
|
49
|
+
|
50
|
+
let(:test_form) { form_class.new(:project => project) }
|
51
|
+
|
52
|
+
it "should pass instance of FreeForm::Builder to freeform_for block" do
|
53
|
+
_view.freeform_for(test_form) do |f|
|
54
|
+
f.should be_instance_of(FreeForm::Builder)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should pass instance of FreeForm::SimpleBuilder to simple_freeform_for block" do
|
59
|
+
_view.simple_freeform_for(test_form) do |f|
|
60
|
+
f.should be_instance_of(FreeForm::SimpleBuilder)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if defined?(FreeForm::FormtasticBuilder)
|
65
|
+
it "should pass instance of FreeForm::FormtasticBuilder to semantic_freeform_for block" do
|
66
|
+
_view.semantic_freeform_for(test_form) do |f|
|
67
|
+
f.should be_instance_of(FreeForm::FormtasticBuilder)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
if defined?(FreeForm::FormtasticBootstrapBuilder)
|
73
|
+
it "should pass instance of FreeForm::FormtasticBootstrapBuilder to semantic_bootstrap_freeform_for block" do
|
74
|
+
_view.semantic_bootstrap_freeform_for(test_form) do |f|
|
75
|
+
f.should be_instance_of(FreeForm::FormtasticBootstrapBuilder)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should append content to end of freeform" do
|
81
|
+
_view.after_freeform(:tasks) { _view.concat("123") }
|
82
|
+
_view.after_freeform(:milestones) { _view.concat("456") }
|
83
|
+
result = _view.freeform_for(test_form) {}
|
84
|
+
result.should include("123456")
|
85
|
+
end
|
86
|
+
|
87
|
+
if Rails.version >= "3.1.0"
|
88
|
+
it "should set multipart when there's a file field" do
|
89
|
+
_view.freeform_for(test_form) do |f|
|
90
|
+
f.fields_for(:tasks) do |t|
|
91
|
+
t.file_field :file
|
92
|
+
end
|
93
|
+
f.link_to_add "Add", :tasks
|
94
|
+
end.should include(" enctype=\"multipart/form-data\" ")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,5 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|