formtastic 0.9.6 → 0.9.7
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.
- data/generators/formtastic/templates/formtastic.rb +1 -1
- data/lib/formtastic.rb +5 -1
- data/spec/input_spec.rb +11 -8
- metadata +2 -2
@@ -25,7 +25,7 @@
|
|
25
25
|
# Formtastic::SemanticFormBuilder.inline_errors = :sentence
|
26
26
|
|
27
27
|
# Set the method to call on label text to transform or format it for human-friendly
|
28
|
-
# reading
|
28
|
+
# reading when formtastic is user without object. Defaults to :humanize.
|
29
29
|
# Formtastic::SemanticFormBuilder.label_str_method = :humanize
|
30
30
|
|
31
31
|
# Set the array of methods to try calling on parent objects in :select and :radio inputs
|
data/lib/formtastic.rb
CHANGED
@@ -1478,7 +1478,11 @@ module Formtastic #:nodoc:
|
|
1478
1478
|
end
|
1479
1479
|
|
1480
1480
|
def humanized_attribute_name(method) #:nodoc:
|
1481
|
-
|
1481
|
+
if @object && @object.class.respond_to?(:human_attribute_name)
|
1482
|
+
@object.class.human_attribute_name(method.to_s)
|
1483
|
+
else
|
1484
|
+
method.to_s.send(@@label_str_method)
|
1485
|
+
end
|
1482
1486
|
end
|
1483
1487
|
|
1484
1488
|
# Internal generic method for looking up localized values within Formtastic
|
data/spec/input_spec.rb
CHANGED
@@ -400,8 +400,9 @@ describe 'SemanticFormBuilder#input' do
|
|
400
400
|
|
401
401
|
describe 'when not provided' do
|
402
402
|
describe 'when localized label is NOT provided' do
|
403
|
-
describe 'and
|
403
|
+
describe 'and object is not given' do
|
404
404
|
it 'should default the humanized method name, passing it down to the label tag' do
|
405
|
+
::Formtastic::SemanticFormBuilder.label_str_method = :humanize
|
405
406
|
|
406
407
|
semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
407
408
|
concat(builder.input(:meta_description))
|
@@ -411,14 +412,16 @@ describe 'SemanticFormBuilder#input' do
|
|
411
412
|
end
|
412
413
|
end
|
413
414
|
|
414
|
-
describe 'and
|
415
|
-
it 'should
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
415
|
+
describe 'and object is given' do
|
416
|
+
it 'should delegate the label logic to class human attribute name and pass it down to the label tag' do
|
417
|
+
@new_post.stub!(:meta_description) # a two word method name
|
418
|
+
@new_post.class.should_receive(:human_attribute_name).with('meta_description').and_return('meta_description'.humanize)
|
419
|
+
|
420
|
+
semantic_form_for(@new_post) do |builder|
|
421
|
+
concat(builder.input(:meta_description))
|
421
422
|
end
|
423
|
+
|
424
|
+
output_buffer.should have_tag("form li label", /#{'meta_description'.humanize}/)
|
422
425
|
end
|
423
426
|
end
|
424
427
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formtastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin French
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-04 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|