formtastic-bootstrap 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +123 -0
- data/LICENSE.txt +20 -0
- data/README.md +159 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/formtastic-bootstrap.gemspec +128 -0
- data/lib/action_view/helpers/text_field_date_helper.rb +166 -0
- data/lib/formtastic-bootstrap.rb +5 -0
- data/lib/formtastic-bootstrap/form_builder.rb +38 -0
- data/lib/formtastic-bootstrap/helpers.rb +19 -0
- data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +47 -0
- data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +37 -0
- data/lib/formtastic-bootstrap/helpers/input_helper.rb +12 -0
- data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +36 -0
- data/lib/formtastic-bootstrap/inputs.rb +28 -0
- data/lib/formtastic-bootstrap/inputs/base.rb +22 -0
- data/lib/formtastic-bootstrap/inputs/base/choices.rb +49 -0
- data/lib/formtastic-bootstrap/inputs/base/errors.rb +48 -0
- data/lib/formtastic-bootstrap/inputs/base/hints.rb +27 -0
- data/lib/formtastic-bootstrap/inputs/base/html.rb +21 -0
- data/lib/formtastic-bootstrap/inputs/base/labelling.rb +18 -0
- data/lib/formtastic-bootstrap/inputs/base/stringish.rb +18 -0
- data/lib/formtastic-bootstrap/inputs/base/timeish.rb +35 -0
- data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +56 -0
- data/lib/formtastic-bootstrap/inputs/boolean_input.rb +33 -0
- data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +35 -0
- data/lib/formtastic-bootstrap/inputs/date_input.rb +16 -0
- data/lib/formtastic-bootstrap/inputs/datetime_input.rb +19 -0
- data/lib/formtastic-bootstrap/inputs/email_input.rb +15 -0
- data/lib/formtastic-bootstrap/inputs/file_input.rb +14 -0
- data/lib/formtastic-bootstrap/inputs/hidden_input.rb +12 -0
- data/lib/formtastic-bootstrap/inputs/number_input.rb +15 -0
- data/lib/formtastic-bootstrap/inputs/password_input.rb +15 -0
- data/lib/formtastic-bootstrap/inputs/phone_input.rb +15 -0
- data/lib/formtastic-bootstrap/inputs/radio_input.rb +32 -0
- data/lib/formtastic-bootstrap/inputs/range_input.rb +15 -0
- data/lib/formtastic-bootstrap/inputs/search_input.rb +15 -0
- data/lib/formtastic-bootstrap/inputs/select_input.rb +14 -0
- data/lib/formtastic-bootstrap/inputs/string_input.rb +15 -0
- data/lib/formtastic-bootstrap/inputs/text_input.rb +14 -0
- data/lib/formtastic-bootstrap/inputs/time_input.rb +16 -0
- data/lib/formtastic-bootstrap/inputs/url_input.rb +14 -0
- data/spec/builder/errors_spec.rb +214 -0
- data/spec/builder/semantic_fields_for_spec.rb +130 -0
- data/spec/helpers/input_helper_spec.rb +956 -0
- data/spec/helpers/inputs_helper_spec.rb +577 -0
- data/spec/inputs/boolean_input_spec.rb +193 -0
- data/spec/inputs/check_boxes_input_spec.rb +439 -0
- data/spec/inputs/date_input_spec.rb +147 -0
- data/spec/inputs/datetime_input_spec.rb +101 -0
- data/spec/inputs/email_input_spec.rb +59 -0
- data/spec/inputs/file_input_spec.rb +63 -0
- data/spec/inputs/hidden_input_spec.rb +122 -0
- data/spec/inputs/number_input_spec.rb +787 -0
- data/spec/inputs/password_input_spec.rb +73 -0
- data/spec/inputs/phone_input_spec.rb +59 -0
- data/spec/inputs/radio_input_spec.rb +240 -0
- data/spec/inputs/range_input_spec.rb +479 -0
- data/spec/inputs/search_input_spec.rb +59 -0
- data/spec/inputs/select_input_spec.rb +567 -0
- data/spec/inputs/string_input_spec.rb +182 -0
- data/spec/inputs/text_input_spec.rb +163 -0
- data/spec/inputs/time_input_spec.rb +206 -0
- data/spec/inputs/url_input_spec.rb +59 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/custom_macros.rb +704 -0
- data/spec/support/depracation.rb +6 -0
- data/spec/support/formtastic_spec_helper.rb +382 -0
- metadata +204 -0
@@ -0,0 +1,382 @@
|
|
1
|
+
# This was lifted right out of Formtastic.
|
2
|
+
module FormtasticSpecHelper
|
3
|
+
include ActionPack
|
4
|
+
include ActionView::Context if defined?(ActionView::Context)
|
5
|
+
include ActionController::RecordIdentifier
|
6
|
+
include ActionView::Helpers::FormHelper
|
7
|
+
include ActionView::Helpers::FormTagHelper
|
8
|
+
include ActionView::Helpers::FormOptionsHelper
|
9
|
+
include ActionView::Helpers::UrlHelper
|
10
|
+
include ActionView::Helpers::TagHelper
|
11
|
+
include ActionView::Helpers::TextHelper
|
12
|
+
include ActionView::Helpers::ActiveRecordHelper if defined?(ActionView::Helpers::ActiveRecordHelper)
|
13
|
+
include ActionView::Helpers::ActiveModelHelper if defined?(ActionView::Helpers::ActiveModelHelper)
|
14
|
+
include ActionView::Helpers::DateHelper
|
15
|
+
include ActionView::Helpers::TextFieldDateHelper # I added this!
|
16
|
+
include ActionView::Helpers::CaptureHelper
|
17
|
+
include ActionView::Helpers::AssetTagHelper
|
18
|
+
include ActiveSupport
|
19
|
+
include ActionController::PolymorphicRoutes if defined?(ActionController::PolymorphicRoutes)
|
20
|
+
|
21
|
+
include Formtastic::Helpers::FormHelper
|
22
|
+
|
23
|
+
def default_input_type(column_type, column_name = :generic_column_name)
|
24
|
+
@new_post.stub!(column_name)
|
25
|
+
@new_post.stub!(:column_for_attribute).and_return(mock('column', :type => column_type)) unless column_type.nil?
|
26
|
+
|
27
|
+
semantic_form_for(@new_post) do |builder|
|
28
|
+
@default_type = builder.send(:default_input_type, column_name)
|
29
|
+
end
|
30
|
+
|
31
|
+
return @default_type
|
32
|
+
end
|
33
|
+
|
34
|
+
def active_model_validator(kind, attributes, options = {})
|
35
|
+
validator = mock("ActiveModel::Validations::#{kind.to_s.titlecase}Validator", :attributes => attributes, :options => options)
|
36
|
+
validator.stub!(:kind).and_return(kind)
|
37
|
+
validator
|
38
|
+
end
|
39
|
+
|
40
|
+
def active_model_presence_validator(attributes, options = {})
|
41
|
+
active_model_validator(:presence, attributes, options)
|
42
|
+
end
|
43
|
+
|
44
|
+
def active_model_length_validator(attributes, options = {})
|
45
|
+
active_model_validator(:length, attributes, options)
|
46
|
+
end
|
47
|
+
|
48
|
+
def active_model_inclusion_validator(attributes, options = {})
|
49
|
+
active_model_validator(:inclusion, attributes, options)
|
50
|
+
end
|
51
|
+
|
52
|
+
def active_model_numericality_validator(attributes, options = {})
|
53
|
+
active_model_validator(:numericality, attributes, options)
|
54
|
+
end
|
55
|
+
|
56
|
+
class ::MongoPost
|
57
|
+
include MongoMapper::Document if defined?(MongoMapper::Document)
|
58
|
+
|
59
|
+
def id
|
60
|
+
end
|
61
|
+
|
62
|
+
def persisted?
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
class ::Post
|
68
|
+
extend ActiveModel::Naming if defined?(ActiveModel::Naming)
|
69
|
+
include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
|
70
|
+
|
71
|
+
def id
|
72
|
+
end
|
73
|
+
|
74
|
+
def persisted?
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
module ::Namespaced
|
79
|
+
class Post
|
80
|
+
extend ActiveModel::Naming if defined?(ActiveModel::Naming)
|
81
|
+
include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
|
82
|
+
|
83
|
+
def id
|
84
|
+
end
|
85
|
+
|
86
|
+
def persisted?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
class ::Author
|
92
|
+
extend ActiveModel::Naming if defined?(ActiveModel::Naming)
|
93
|
+
include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
|
94
|
+
|
95
|
+
def to_label
|
96
|
+
end
|
97
|
+
|
98
|
+
def persisted?
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class ::HashBackedAuthor < Hash
|
103
|
+
extend ActiveModel::Naming if defined?(ActiveModel::Naming)
|
104
|
+
include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
|
105
|
+
def persisted?; false; end
|
106
|
+
def name
|
107
|
+
'hash backed author'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
class ::Continent
|
112
|
+
extend ActiveModel::Naming if defined?(ActiveModel::Naming)
|
113
|
+
include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
|
114
|
+
end
|
115
|
+
|
116
|
+
class ::PostModel
|
117
|
+
extend ActiveModel::Naming if defined?(ActiveModel::Naming)
|
118
|
+
include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
|
119
|
+
end
|
120
|
+
|
121
|
+
def _routes
|
122
|
+
url_helpers = mock('url_helpers')
|
123
|
+
url_helpers.stub!(:hash_for_posts_path).and_return({})
|
124
|
+
url_helpers.stub!(:hash_for_post_path).and_return({})
|
125
|
+
url_helpers.stub!(:hash_for_post_models_path).and_return({})
|
126
|
+
url_helpers.stub!(:hash_for_authors_path).and_return({})
|
127
|
+
|
128
|
+
mock('_routes',
|
129
|
+
:url_helpers => url_helpers,
|
130
|
+
:url_for => "/mock/path"
|
131
|
+
)
|
132
|
+
end
|
133
|
+
|
134
|
+
def controller
|
135
|
+
mock('controller', :controller_path= => '', :params => {})
|
136
|
+
end
|
137
|
+
|
138
|
+
def default_url_options
|
139
|
+
{}
|
140
|
+
end
|
141
|
+
|
142
|
+
def mock_everything
|
143
|
+
|
144
|
+
# Resource-oriented styles like form_for(@post) will expect a path method for the object,
|
145
|
+
# so we're defining some here.
|
146
|
+
def post_models_path(*args); "/postmodels/1"; end
|
147
|
+
|
148
|
+
def post_path(*args); "/posts/1"; end
|
149
|
+
def posts_path(*args); "/posts"; end
|
150
|
+
def new_post_path(*args); "/posts/new"; end
|
151
|
+
|
152
|
+
def author_path(*args); "/authors/1"; end
|
153
|
+
def authors_path(*args); "/authors"; end
|
154
|
+
def new_author_path(*args); "/authors/new"; end
|
155
|
+
|
156
|
+
@fred = ::Author.new
|
157
|
+
@fred.stub!(:class).and_return(::Author)
|
158
|
+
@fred.stub!(:to_label).and_return('Fred Smith')
|
159
|
+
@fred.stub!(:login).and_return('fred_smith')
|
160
|
+
@fred.stub!(:age).and_return(27)
|
161
|
+
@fred.stub!(:id).and_return(37)
|
162
|
+
@fred.stub!(:new_record?).and_return(false)
|
163
|
+
@fred.stub!(:errors).and_return(mock('errors', :[] => nil))
|
164
|
+
@fred.stub!(:to_key).and_return(nil)
|
165
|
+
@fred.stub!(:persisted?).and_return(nil)
|
166
|
+
@fred.stub!(:name).and_return('Fred')
|
167
|
+
|
168
|
+
@bob = ::Author.new
|
169
|
+
@bob.stub!(:to_label).and_return('Bob Rock')
|
170
|
+
@bob.stub!(:login).and_return('bob')
|
171
|
+
@bob.stub!(:age).and_return(43)
|
172
|
+
@bob.stub!(:created_at)
|
173
|
+
@bob.stub!(:id).and_return(42)
|
174
|
+
@bob.stub!(:posts).and_return([])
|
175
|
+
@bob.stub!(:post_ids).and_return([])
|
176
|
+
@bob.stub!(:new_record?).and_return(false)
|
177
|
+
@bob.stub!(:errors).and_return(mock('errors', :[] => nil))
|
178
|
+
@bob.stub!(:to_key).and_return(nil)
|
179
|
+
@bob.stub!(:persisted?).and_return(nil)
|
180
|
+
@bob.stub!(:name).and_return('Bob')
|
181
|
+
|
182
|
+
@james = ::Author.new
|
183
|
+
@james.stub!(:to_label).and_return('James Shock')
|
184
|
+
@james.stub!(:login).and_return('james')
|
185
|
+
@james.stub!(:age).and_return(38)
|
186
|
+
@james.stub!(:id).and_return(75)
|
187
|
+
@james.stub!(:posts).and_return([])
|
188
|
+
@james.stub!(:post_ids).and_return([])
|
189
|
+
@james.stub!(:new_record?).and_return(false)
|
190
|
+
@james.stub!(:errors).and_return(mock('errors', :[] => nil))
|
191
|
+
@james.stub!(:to_key).and_return(nil)
|
192
|
+
@james.stub!(:persisted?).and_return(nil)
|
193
|
+
@james.stub!(:name).and_return('James')
|
194
|
+
|
195
|
+
|
196
|
+
::Author.stub!(:scoped).and_return(::Author)
|
197
|
+
::Author.stub!(:find).and_return([@fred, @bob])
|
198
|
+
::Author.stub!(:all).and_return([@fred, @bob])
|
199
|
+
::Author.stub!(:where).and_return([@fred, @bob])
|
200
|
+
::Author.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
|
201
|
+
::Author.stub!(:human_name).and_return('::Author')
|
202
|
+
::Author.stub!(:reflect_on_association).and_return { |column_name| mock('reflection', :options => {}, :klass => Post, :macro => :has_many) if column_name == :posts }
|
203
|
+
::Author.stub!(:content_columns).and_return([mock('column', :name => 'login'), mock('column', :name => 'created_at')])
|
204
|
+
::Author.stub!(:to_key).and_return(nil)
|
205
|
+
::Author.stub!(:persisted?).and_return(nil)
|
206
|
+
|
207
|
+
@hash_backed_author = HashBackedAuthor.new
|
208
|
+
|
209
|
+
# Sometimes we need a mock @post object and some Authors for belongs_to
|
210
|
+
@new_post = mock('post')
|
211
|
+
@new_post.stub!(:class).and_return(::Post)
|
212
|
+
@new_post.stub!(:id).and_return(nil)
|
213
|
+
@new_post.stub!(:new_record?).and_return(true)
|
214
|
+
@new_post.stub!(:errors).and_return(mock('errors', :[] => nil))
|
215
|
+
@new_post.stub!(:author).and_return(nil)
|
216
|
+
@new_post.stub!(:author_attributes=).and_return(nil)
|
217
|
+
@new_post.stub!(:authors).and_return([@fred])
|
218
|
+
@new_post.stub!(:authors_attributes=)
|
219
|
+
@new_post.stub!(:reviewer).and_return(nil)
|
220
|
+
@new_post.stub!(:main_post).and_return(nil)
|
221
|
+
@new_post.stub!(:sub_posts).and_return([]) #TODO should be a mock with methods for adding sub posts
|
222
|
+
@new_post.stub!(:to_key).and_return(nil)
|
223
|
+
@new_post.stub!(:to_model).and_return(@new_post)
|
224
|
+
@new_post.stub!(:persisted?).and_return(nil)
|
225
|
+
|
226
|
+
@freds_post = mock('post')
|
227
|
+
@freds_post.stub!(:to_ary)
|
228
|
+
@freds_post.stub!(:class).and_return(::Post)
|
229
|
+
@freds_post.stub!(:to_label).and_return('Fred Smith')
|
230
|
+
@freds_post.stub!(:id).and_return(19)
|
231
|
+
@freds_post.stub!(:title).and_return("Hello World")
|
232
|
+
@freds_post.stub!(:author).and_return(@fred)
|
233
|
+
@freds_post.stub!(:author_id).and_return(@fred.id)
|
234
|
+
@freds_post.stub!(:authors).and_return([@fred])
|
235
|
+
@freds_post.stub!(:author_ids).and_return([@fred.id])
|
236
|
+
@freds_post.stub!(:new_record?).and_return(false)
|
237
|
+
@freds_post.stub!(:errors).and_return(mock('errors', :[] => nil))
|
238
|
+
@freds_post.stub!(:to_key).and_return(nil)
|
239
|
+
@freds_post.stub!(:persisted?).and_return(nil)
|
240
|
+
@fred.stub!(:posts).and_return([@freds_post])
|
241
|
+
@fred.stub!(:post_ids).and_return([@freds_post.id])
|
242
|
+
|
243
|
+
::Post.stub!(:scoped).and_return(::Post)
|
244
|
+
::Post.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
|
245
|
+
::Post.stub!(:human_name).and_return('Post')
|
246
|
+
::Post.stub!(:reflect_on_all_validations).and_return([])
|
247
|
+
::Post.stub!(:reflect_on_validations_for).and_return([])
|
248
|
+
::Post.stub!(:reflections).and_return({})
|
249
|
+
::Post.stub!(:reflect_on_association).and_return do |column_name|
|
250
|
+
case column_name
|
251
|
+
when :author, :author_status
|
252
|
+
mock = mock('reflection', :options => {}, :klass => ::Author, :macro => :belongs_to)
|
253
|
+
mock.stub!(:[]).with(:class_name).and_return("Author")
|
254
|
+
mock
|
255
|
+
when :reviewer
|
256
|
+
mock = mock('reflection', :options => {:class_name => 'Author'}, :klass => ::Author, :macro => :belongs_to)
|
257
|
+
mock.stub!(:[]).with(:class_name).and_return("Author")
|
258
|
+
mock
|
259
|
+
when :authors
|
260
|
+
mock('reflection', :options => {}, :klass => ::Author, :macro => :has_and_belongs_to_many)
|
261
|
+
when :sub_posts
|
262
|
+
mock('reflection', :options => {}, :klass => ::Post, :macro => :has_many)
|
263
|
+
when :main_post
|
264
|
+
mock('reflection', :options => {}, :klass => ::Post, :macro => :belongs_to)
|
265
|
+
when :mongoid_reviewer
|
266
|
+
mock('reflection', :options => nil, :klass => ::Author, :macro => :referenced_in, :foreign_key => "reviewer_id") # custom id
|
267
|
+
end
|
268
|
+
end
|
269
|
+
::Post.stub!(:find).and_return([@freds_post])
|
270
|
+
::Post.stub!(:all).and_return([@freds_post])
|
271
|
+
::Post.stub!(:where).and_return([@freds_post])
|
272
|
+
::Post.stub!(:content_columns).and_return([mock('column', :name => 'title'), mock('column', :name => 'body'), mock('column', :name => 'created_at')])
|
273
|
+
::Post.stub!(:to_key).and_return(nil)
|
274
|
+
::Post.stub!(:persisted?).and_return(nil)
|
275
|
+
::Post.stub!(:to_ary)
|
276
|
+
|
277
|
+
::MongoPost.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
|
278
|
+
::MongoPost.stub!(:human_name).and_return('MongoPost')
|
279
|
+
::MongoPost.stub!(:associations).and_return({
|
280
|
+
:sub_posts => mock('reflection', :options => {:polymorphic => true}, :klass => ::MongoPost, :macro => :has_many),
|
281
|
+
:options => []
|
282
|
+
})
|
283
|
+
::MongoPost.stub!(:find).and_return([@freds_post])
|
284
|
+
::MongoPost.stub!(:all).and_return([@freds_post])
|
285
|
+
::MongoPost.stub!(:where).and_return([@freds_post])
|
286
|
+
::MongoPost.stub!(:to_key).and_return(nil)
|
287
|
+
::MongoPost.stub!(:persisted?).and_return(nil)
|
288
|
+
::MongoPost.stub!(:to_ary)
|
289
|
+
::MongoPost.stub!(:model_name).and_return( mock(:model_name_mock, :singular => "post", :plural => "posts", :param_key => "post", :route_key => "posts") )
|
290
|
+
|
291
|
+
@new_mm_post = mock('mm_post')
|
292
|
+
@new_mm_post.stub!(:class).and_return(::MongoPost)
|
293
|
+
@new_mm_post.stub!(:id).and_return(nil)
|
294
|
+
@new_mm_post.stub!(:new_record?).and_return(true)
|
295
|
+
@new_mm_post.stub!(:errors).and_return(mock('errors', :[] => nil))
|
296
|
+
@new_mm_post.stub!(:title).and_return("Hello World")
|
297
|
+
@new_mm_post.stub!(:sub_posts).and_return([]) #TODO should be a mock with methods for adding sub posts
|
298
|
+
@new_mm_post.stub!(:to_key).and_return(nil)
|
299
|
+
@new_mm_post.stub!(:to_model).and_return(@new_mm_post)
|
300
|
+
@new_mm_post.stub!(:persisted?).and_return(nil)
|
301
|
+
|
302
|
+
@mock_file = mock('file')
|
303
|
+
Formtastic::FormBuilder.file_methods.each do |method|
|
304
|
+
@mock_file.stub!(method).and_return(true)
|
305
|
+
end
|
306
|
+
|
307
|
+
@new_post.stub!(:title)
|
308
|
+
@new_post.stub!(:email)
|
309
|
+
@new_post.stub!(:url)
|
310
|
+
@new_post.stub!(:phone)
|
311
|
+
@new_post.stub!(:search)
|
312
|
+
@new_post.stub!(:to_ary)
|
313
|
+
@new_post.stub!(:body)
|
314
|
+
@new_post.stub!(:published)
|
315
|
+
@new_post.stub!(:publish_at)
|
316
|
+
@new_post.stub!(:created_at)
|
317
|
+
@new_post.stub!(:secret).and_return(1)
|
318
|
+
@new_post.stub!(:url)
|
319
|
+
@new_post.stub!(:email)
|
320
|
+
@new_post.stub!(:search)
|
321
|
+
@new_post.stub!(:phone)
|
322
|
+
@new_post.stub!(:time_zone)
|
323
|
+
@new_post.stub!(:category_name)
|
324
|
+
@new_post.stub!(:allow_comments).and_return(true)
|
325
|
+
@new_post.stub!(:answer_comments)
|
326
|
+
@new_post.stub!(:country)
|
327
|
+
@new_post.stub!(:country_subdivision)
|
328
|
+
@new_post.stub!(:country_code)
|
329
|
+
@new_post.stub!(:document).and_return(@mock_file)
|
330
|
+
@new_post.stub!(:column_for_attribute).with(:meta_description).and_return(mock('column', :type => :string, :limit => 255))
|
331
|
+
@new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :string, :limit => 50))
|
332
|
+
@new_post.stub!(:column_for_attribute).with(:body).and_return(mock('column', :type => :text))
|
333
|
+
@new_post.stub!(:column_for_attribute).with(:published).and_return(mock('column', :type => :boolean))
|
334
|
+
@new_post.stub!(:column_for_attribute).with(:publish_at).and_return(mock('column', :type => :date))
|
335
|
+
@new_post.stub!(:column_for_attribute).with(:time_zone).and_return(mock('column', :type => :string))
|
336
|
+
@new_post.stub!(:column_for_attribute).with(:allow_comments).and_return(mock('column', :type => :boolean))
|
337
|
+
@new_post.stub!(:column_for_attribute).with(:author).and_return(mock('column', :type => :integer))
|
338
|
+
@new_post.stub!(:column_for_attribute).with(:country).and_return(mock('column', :type => :string, :limit => 255))
|
339
|
+
@new_post.stub!(:column_for_attribute).with(:country_subdivision).and_return(mock('column', :type => :string, :limit => 255))
|
340
|
+
@new_post.stub!(:column_for_attribute).with(:country_code).and_return(mock('column', :type => :string, :limit => 255))
|
341
|
+
@new_post.stub!(:column_for_attribute).with(:email).and_return(mock('column', :type => :string, :limit => 255))
|
342
|
+
@new_post.stub!(:column_for_attribute).with(:url).and_return(mock('column', :type => :string, :limit => 255))
|
343
|
+
@new_post.stub!(:column_for_attribute).with(:phone).and_return(mock('column', :type => :string, :limit => 255))
|
344
|
+
@new_post.stub!(:column_for_attribute).with(:search).and_return(mock('column', :type => :string, :limit => 255))
|
345
|
+
@new_post.stub!(:column_for_attribute).with(:document).and_return(nil)
|
346
|
+
|
347
|
+
@new_post.stub!(:author).and_return(@bob)
|
348
|
+
@new_post.stub!(:author_id).and_return(@bob.id)
|
349
|
+
|
350
|
+
@new_post.stub!(:reviewer).and_return(@fred)
|
351
|
+
@new_post.stub!(:reviewer_id).and_return(@fred.id)
|
352
|
+
|
353
|
+
@new_post.should_receive(:publish_at=).any_number_of_times
|
354
|
+
@new_post.should_receive(:title=).any_number_of_times
|
355
|
+
@new_post.stub!(:main_post_id).and_return(nil)
|
356
|
+
|
357
|
+
end
|
358
|
+
|
359
|
+
def self.included(base)
|
360
|
+
base.class_eval do
|
361
|
+
|
362
|
+
attr_accessor :output_buffer
|
363
|
+
|
364
|
+
def protect_against_forgery?
|
365
|
+
false
|
366
|
+
end
|
367
|
+
|
368
|
+
def _helpers
|
369
|
+
FakeHelpersModule
|
370
|
+
end
|
371
|
+
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
def with_config(config_method_name, value, &block)
|
376
|
+
old_value = FormtasticBootstrap::FormBuilder.send(config_method_name)
|
377
|
+
FormtasticBootstrap::FormBuilder.send(:"#{config_method_name}=", value)
|
378
|
+
yield
|
379
|
+
FormtasticBootstrap::FormBuilder.send(:"#{config_method_name}=", old_value)
|
380
|
+
end
|
381
|
+
|
382
|
+
end
|
metadata
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: formtastic-bootstrap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Matthew Bellantoni
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-11-08 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: formtastic
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rails
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: bundler
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *id004
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: jeweler
|
61
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *id005
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rcov
|
72
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *id006
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec_tag_matchers
|
83
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: *id007
|
92
|
+
description: Formtastic form builder to generate Twitter Bootstrap-friendly markup.
|
93
|
+
email: mjbellantoni@yahoo.com
|
94
|
+
executables: []
|
95
|
+
|
96
|
+
extensions: []
|
97
|
+
|
98
|
+
extra_rdoc_files:
|
99
|
+
- LICENSE.txt
|
100
|
+
- README.md
|
101
|
+
files:
|
102
|
+
- .document
|
103
|
+
- .rspec
|
104
|
+
- Gemfile
|
105
|
+
- Gemfile.lock
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- VERSION
|
110
|
+
- formtastic-bootstrap.gemspec
|
111
|
+
- lib/action_view/helpers/text_field_date_helper.rb
|
112
|
+
- lib/formtastic-bootstrap.rb
|
113
|
+
- lib/formtastic-bootstrap/form_builder.rb
|
114
|
+
- lib/formtastic-bootstrap/helpers.rb
|
115
|
+
- lib/formtastic-bootstrap/helpers/buttons_helper.rb
|
116
|
+
- lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb
|
117
|
+
- lib/formtastic-bootstrap/helpers/input_helper.rb
|
118
|
+
- lib/formtastic-bootstrap/helpers/inputs_helper.rb
|
119
|
+
- lib/formtastic-bootstrap/inputs.rb
|
120
|
+
- lib/formtastic-bootstrap/inputs/base.rb
|
121
|
+
- lib/formtastic-bootstrap/inputs/base/choices.rb
|
122
|
+
- lib/formtastic-bootstrap/inputs/base/errors.rb
|
123
|
+
- lib/formtastic-bootstrap/inputs/base/hints.rb
|
124
|
+
- lib/formtastic-bootstrap/inputs/base/html.rb
|
125
|
+
- lib/formtastic-bootstrap/inputs/base/labelling.rb
|
126
|
+
- lib/formtastic-bootstrap/inputs/base/stringish.rb
|
127
|
+
- lib/formtastic-bootstrap/inputs/base/timeish.rb
|
128
|
+
- lib/formtastic-bootstrap/inputs/base/wrapping.rb
|
129
|
+
- lib/formtastic-bootstrap/inputs/boolean_input.rb
|
130
|
+
- lib/formtastic-bootstrap/inputs/check_boxes_input.rb
|
131
|
+
- lib/formtastic-bootstrap/inputs/date_input.rb
|
132
|
+
- lib/formtastic-bootstrap/inputs/datetime_input.rb
|
133
|
+
- lib/formtastic-bootstrap/inputs/email_input.rb
|
134
|
+
- lib/formtastic-bootstrap/inputs/file_input.rb
|
135
|
+
- lib/formtastic-bootstrap/inputs/hidden_input.rb
|
136
|
+
- lib/formtastic-bootstrap/inputs/number_input.rb
|
137
|
+
- lib/formtastic-bootstrap/inputs/password_input.rb
|
138
|
+
- lib/formtastic-bootstrap/inputs/phone_input.rb
|
139
|
+
- lib/formtastic-bootstrap/inputs/radio_input.rb
|
140
|
+
- lib/formtastic-bootstrap/inputs/range_input.rb
|
141
|
+
- lib/formtastic-bootstrap/inputs/search_input.rb
|
142
|
+
- lib/formtastic-bootstrap/inputs/select_input.rb
|
143
|
+
- lib/formtastic-bootstrap/inputs/string_input.rb
|
144
|
+
- lib/formtastic-bootstrap/inputs/text_input.rb
|
145
|
+
- lib/formtastic-bootstrap/inputs/time_input.rb
|
146
|
+
- lib/formtastic-bootstrap/inputs/url_input.rb
|
147
|
+
- spec/builder/errors_spec.rb
|
148
|
+
- spec/builder/semantic_fields_for_spec.rb
|
149
|
+
- spec/helpers/input_helper_spec.rb
|
150
|
+
- spec/helpers/inputs_helper_spec.rb
|
151
|
+
- spec/inputs/boolean_input_spec.rb
|
152
|
+
- spec/inputs/check_boxes_input_spec.rb
|
153
|
+
- spec/inputs/date_input_spec.rb
|
154
|
+
- spec/inputs/datetime_input_spec.rb
|
155
|
+
- spec/inputs/email_input_spec.rb
|
156
|
+
- spec/inputs/file_input_spec.rb
|
157
|
+
- spec/inputs/hidden_input_spec.rb
|
158
|
+
- spec/inputs/number_input_spec.rb
|
159
|
+
- spec/inputs/password_input_spec.rb
|
160
|
+
- spec/inputs/phone_input_spec.rb
|
161
|
+
- spec/inputs/radio_input_spec.rb
|
162
|
+
- spec/inputs/range_input_spec.rb
|
163
|
+
- spec/inputs/search_input_spec.rb
|
164
|
+
- spec/inputs/select_input_spec.rb
|
165
|
+
- spec/inputs/string_input_spec.rb
|
166
|
+
- spec/inputs/text_input_spec.rb
|
167
|
+
- spec/inputs/time_input_spec.rb
|
168
|
+
- spec/inputs/url_input_spec.rb
|
169
|
+
- spec/spec_helper.rb
|
170
|
+
- spec/support/custom_macros.rb
|
171
|
+
- spec/support/depracation.rb
|
172
|
+
- spec/support/formtastic_spec_helper.rb
|
173
|
+
homepage: http://github.com/mjbellantoni/formtastic-bootstrap
|
174
|
+
licenses:
|
175
|
+
- MIT
|
176
|
+
post_install_message:
|
177
|
+
rdoc_options: []
|
178
|
+
|
179
|
+
require_paths:
|
180
|
+
- lib
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
hash: -231550788374824554
|
187
|
+
segments:
|
188
|
+
- 0
|
189
|
+
version: "0"
|
190
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
none: false
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: "0"
|
196
|
+
requirements: []
|
197
|
+
|
198
|
+
rubyforge_project:
|
199
|
+
rubygems_version: 1.8.10
|
200
|
+
signing_key:
|
201
|
+
specification_version: 3
|
202
|
+
summary: Formtastic form builder to generate Twitter Bootstrap-friendly markup.
|
203
|
+
test_files: []
|
204
|
+
|