simple_form 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of simple_form might be problematic. Click here for more details.

@@ -238,7 +238,7 @@ Creates a collection of radio inputs with labels associated (same API as collect
238
238
  Creates a collection of check boxes with labels associated (same API as collection_select):
239
239
 
240
240
  form_for @user do |f|
241
- f.collection_check_box :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
241
+ f.collection_check_boxes :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
242
242
  end
243
243
 
244
244
  <input name="user[options][]" type="hidden" value="" />
@@ -36,8 +36,8 @@ module SimpleForm
36
36
 
37
37
  default_html_options = default_html_options_for_collection(item, value, options, html_options)
38
38
 
39
- radio = radio_button(attribute, value, default_html_options)
40
- result << label("#{attribute}_#{value}", radio << text.to_s, :class => "collection_radio")
39
+ result << radio_button(attribute, value, default_html_options) <<
40
+ label("#{attribute}_#{value}", text, :class => "collection_radio")
41
41
  end
42
42
  end
43
43
 
@@ -48,15 +48,15 @@ module SimpleForm
48
48
  # == Examples
49
49
  #
50
50
  # form_for @user do |f|
51
- # f.collection_check_box :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
51
+ # f.collection_check_boxes :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
52
52
  # end
53
53
  #
54
54
  # <input name="user[options][]" type="hidden" value="" />
55
55
  # <input id="user_options_true" name="user[options][]" type="checkbox" value="true" />
56
- # <label class="collection_check_box" for="user_options_true">Yes</label>
56
+ # <label class="collection_check_boxes" for="user_options_true">Yes</label>
57
57
  # <input name="user[options][]" type="hidden" value="" />
58
58
  # <input id="user_options_false" name="user[options][]" type="checkbox" value="false" />
59
- # <label class="collection_check_box" for="user_options_false">No</label>
59
+ # <label class="collection_check_boxes" for="user_options_false">No</label>
60
60
  #
61
61
  # == Options
62
62
  #
@@ -76,8 +76,8 @@ module SimpleForm
76
76
  default_html_options = default_html_options_for_collection(item, value, options, html_options)
77
77
  default_html_options[:multiple] = true
78
78
 
79
- check_box = check_box(attribute, default_html_options, value, '')
80
- result << label("#{attribute}_#{value}", check_box << text.to_s, :class => "collection_check_boxes")
79
+ result << check_box(attribute, default_html_options, value, '') <<
80
+ label("#{attribute}_#{value}", text, :class => "collection_check_boxes")
81
81
  end
82
82
  end
83
83
 
@@ -101,7 +101,7 @@ module SimpleForm
101
101
  # Generate default options for collection helpers, such as :checked and
102
102
  # :disabled.
103
103
  def default_html_options_for_collection(item, value, options, html_options) #:nodoc:
104
- returning(html_options.dup) do |default_html_options|
104
+ html_options.dup.tap do |default_html_options|
105
105
  [:checked, :disabled].each do |option|
106
106
  next unless options[option]
107
107
 
@@ -28,8 +28,7 @@ module SimpleForm
28
28
  end
29
29
 
30
30
  def label_text
31
- result = SimpleForm.label_text.call(raw_label_text, required_label_text)
32
- result.respond_to?(:html_safe) ? result.html_safe : result
31
+ html_safe(SimpleForm.label_text.call(raw_label_text, required_label_text))
33
32
  end
34
33
 
35
34
  def label_target
@@ -66,4 +65,4 @@ module SimpleForm
66
65
  end
67
66
  end
68
67
  end
69
- end
68
+ end
@@ -172,7 +172,7 @@ module SimpleForm
172
172
  klass.all(finders)
173
173
  end
174
174
 
175
- returning(input(attribute, options)) { @reflection = nil }
175
+ input(attribute, options).tap { @reflection = nil }
176
176
  end
177
177
 
178
178
  # Creates a button:
@@ -39,7 +39,8 @@ module SimpleForm
39
39
  send(component)
40
40
  end
41
41
  content.compact!
42
- wrap(content.join.html_safe).html_safe
42
+ content = html_safe(content.join)
43
+ html_safe(wrap(content))
43
44
  end
44
45
 
45
46
  protected
@@ -64,6 +65,17 @@ module SimpleForm
64
65
  html_options
65
66
  end
66
67
 
68
+ # Ensure we make html safe only if it responds to it.
69
+ def html_safe(content)
70
+ if content.respond_to?(:html_safe)
71
+ content.html_safe
72
+ elsif content.respond_to?(:html_safe!)
73
+ content.html_safe!
74
+ else
75
+ content
76
+ end
77
+ end
78
+
67
79
  # Lookup translations for the given namespace using I18n, based on object name,
68
80
  # actual action and attribute name. Lookup priority as follows:
69
81
  #
@@ -3,9 +3,9 @@ en:
3
3
  "yes": 'Yes'
4
4
  "no": 'No'
5
5
  buttons:
6
- create: 'Create {{model}}'
7
- update: 'Update {{model}}'
8
- submit: 'Submit {{model}}'
6
+ create: 'Create %{model}'
7
+ update: 'Update %{model}'
8
+ submit: 'Submit %{model}'
9
9
  required:
10
10
  text: 'required'
11
11
  mark: '*'
@@ -1,3 +1,3 @@
1
1
  module SimpleForm
2
- VERSION = "1.0.3".freeze
2
+ VERSION = "1.0.4".freeze
3
3
  end
@@ -366,7 +366,7 @@ class FormBuilderTest < ActionView::TestCase
366
366
 
367
367
  test 'builder should create object buttons with localized labels' do
368
368
  store_translations(:en, :simple_form => { :buttons => {
369
- :create => "Criar {{model}}", :update => "Atualizar {{model}}" }}) do
369
+ :create => "Criar %{model}", :update => "Atualizar %{model}" }}) do
370
370
  with_button_for @user, :submit
371
371
  assert_select 'form input[type=submit][value=Atualizar User]'
372
372
 
@@ -377,7 +377,7 @@ class FormBuilderTest < ActionView::TestCase
377
377
  end
378
378
 
379
379
  test 'builder should create non object buttons with localized labels' do
380
- store_translations(:en, :simple_form => { :buttons => { :submit => "Enviar {{model}}" }}) do
380
+ store_translations(:en, :simple_form => { :buttons => { :submit => "Enviar %{model}" }}) do
381
381
  with_button_for :post, :submit
382
382
  assert_select 'form input[type=submit][value=Enviar Post]'
383
383
  end
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
+ require 'mocha'
3
4
 
4
5
  require 'action_controller'
5
6
  require 'action_view/test_case'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 3
10
- version: 1.0.3
9
+ - 4
10
+ version: 1.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Jos\xC3\xA9 Valim"
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-08-31 00:00:00 +02:00
19
+ date: 2010-10-08 00:00:00 -03:00
20
20
  default_executable:
21
21
  dependencies: []
22
22