simple_form 1.1.1 → 1.1.2

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.

@@ -7,10 +7,14 @@ module SimpleForm
7
7
 
8
8
  def input_html_options
9
9
  input_options = super
10
- input_options[:class] = "string #{input_options[:class]}" unless input_type == :string
11
10
  input_options[:size] ||= [limit, SimpleForm.default_input_size].compact.min
12
11
  input_options[:maxlength] ||= limit if limit
13
- input_options[:type] ||= input_type
12
+
13
+ unless input_type == :string
14
+ input_options[:type] ||= input_type
15
+ input_options[:class] = "string #{input_options[:class]}"
16
+ end
17
+
14
18
  input_options
15
19
  end
16
20
 
@@ -21,4 +25,4 @@ module SimpleForm
21
25
  end
22
26
  end
23
27
  end
24
- end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleForm
2
- VERSION = "1.1.1".freeze
2
+ VERSION = "1.1.2".freeze
3
3
  end
data/test/inputs_test.rb CHANGED
@@ -29,22 +29,22 @@ class InputTest < ActionView::TestCase
29
29
  # TextFieldInput
30
30
  test 'input should map text field to string attribute' do
31
31
  with_input_for @user, :name, :string
32
- assert_select 'input[name=\'user[name]\'][id=user_name][value=New in Simple Form!]'
32
+ assert_select 'input[name=\'user[name]\'][id=user_name][value=New in Simple Form!][type=text]'
33
33
  end
34
34
 
35
35
  test 'input should generate an integer text field for integer attributes ' do
36
36
  with_input_for @user, :age, :integer
37
- assert_select 'input.integer#user_age'
37
+ assert_select 'input[type=text].integer#user_age'
38
38
  end
39
39
 
40
40
  test 'input should generate a float text field for float attributes ' do
41
41
  with_input_for @user, :age, :float
42
- assert_select 'input.float#user_age'
42
+ assert_select 'input[type=text].float#user_age'
43
43
  end
44
44
 
45
45
  test 'input should generate a decimal text field for decimal attributes ' do
46
46
  with_input_for @user, :age, :decimal
47
- assert_select 'input.decimal#user_age'
47
+ assert_select 'input[type=text].decimal#user_age'
48
48
  end
49
49
 
50
50
  test 'input should use default text size for decimal attributes' do
@@ -19,8 +19,8 @@ class Company < Struct.new(:id, :name)
19
19
  (a || {}).merge(b || {})
20
20
  end
21
21
 
22
- def new_record?
23
- false
22
+ def persisted?
23
+ true
24
24
  end
25
25
  end
26
26
 
@@ -42,8 +42,8 @@ class User < OpenStruct
42
42
  @new_record = true
43
43
  end
44
44
 
45
- def new_record?
46
- @new_record || false
45
+ def persisted?
46
+ !(@new_record || false)
47
47
  end
48
48
 
49
49
  def company_attributes=(*)
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 1
8
+ - 2
9
+ version: 1.1.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - "Jos\xC3\xA9 Valim"
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2010-02-19 00:00:00 +01:00
18
+ date: 2010-03-16 00:00:00 +01:00
14
19
  default_executable:
15
20
  dependencies: []
16
21
 
@@ -65,18 +70,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
70
  requirements:
66
71
  - - ">="
67
72
  - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
68
75
  version: "0"
69
- version:
70
76
  required_rubygems_version: !ruby/object:Gem::Requirement
71
77
  requirements:
72
78
  - - ">="
73
79
  - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
74
82
  version: "0"
75
- version:
76
83
  requirements: []
77
84
 
78
85
  rubyforge_project:
79
- rubygems_version: 1.3.5
86
+ rubygems_version: 1.3.6
80
87
  signing_key:
81
88
  specification_version: 3
82
89
  summary: Forms made easy!
@@ -89,10 +96,6 @@ test_files:
89
96
  - test/form_builder_test.rb
90
97
  - test/inputs_test.rb
91
98
  - test/simple_form_test.rb
92
- - test/support/country_select/init.rb
93
- - test/support/country_select/install.rb
94
- - test/support/country_select/lib/country_select.rb
95
- - test/support/country_select/uninstall.rb
96
99
  - test/support/misc_helpers.rb
97
100
  - test/support/mock_controller.rb
98
101
  - test/support/mock_response.rb
@@ -1 +0,0 @@
1
- require 'country_select'
@@ -1,2 +0,0 @@
1
- # Install hook code here
2
- puts "The list of countries provided by this plugin may offend some users. Please review it carefully before you use it"
@@ -1,84 +0,0 @@
1
- # CountrySelect
2
- module ActionView
3
- module Helpers
4
- module FormOptionsHelper
5
- # Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
6
- def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
7
- InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
8
- end
9
- # Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to
10
- # have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so
11
- # that they will be listed above the rest of the (long) list.
12
- #
13
- # NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
14
- def country_options_for_select(selected = nil, priority_countries = nil)
15
- country_options = ""
16
-
17
- if priority_countries
18
- country_options += options_for_select(priority_countries, selected)
19
- country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
20
- end
21
-
22
- return country_options + options_for_select(COUNTRIES, selected)
23
- end
24
- # All the countries included in the country_options output.
25
- COUNTRIES = ["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola",
26
- "Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria",
27
- "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin",
28
- "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil",
29
- "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia",
30
- "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
31
- "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo",
32
- "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba",
33
- "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt",
34
- "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)",
35
- "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia",
36
- "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea",
37
- "Guinea-Bissau", "Guyana", "Haiti", "Heard and McDonald Islands", "Holy See (Vatican City State)",
38
- "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran, Islamic Republic of", "Iraq",
39
- "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya",
40
- "Kiribati", "Korea, Democratic People's Republic of", "Korea, Republic of", "Kuwait", "Kyrgyzstan",
41
- "Lao People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya",
42
- "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia, The Former Yugoslav Republic Of",
43
- "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique",
44
- "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of",
45
- "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru",
46
- "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger",
47
- "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau",
48
- "Palestinian Territory, Occupied", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines",
49
- "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation",
50
- "Rwanda", "Saint Barthelemy", "Saint Helena", "Saint Kitts and Nevis", "Saint Lucia",
51
- "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino",
52
- "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore",
53
- "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa",
54
- "South Georgia and the South Sandwich Islands", "Spain", "Sri Lanka", "Sudan", "Suriname",
55
- "Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic",
56
- "Taiwan, Province of China", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Timor-Leste",
57
- "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan",
58
- "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom",
59
- "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela",
60
- "Viet Nam", "Virgin Islands, British", "Virgin Islands, U.S.", "Wallis and Futuna", "Western Sahara",
61
- "Yemen", "Zambia", "Zimbabwe"] unless const_defined?("COUNTRIES")
62
- end
63
-
64
- class InstanceTag
65
- def to_country_select_tag(priority_countries, options, html_options)
66
- html_options = html_options.stringify_keys
67
- add_default_name_and_id(html_options)
68
- value = value(object)
69
- content_tag("select",
70
- add_options(
71
- country_options_for_select(value, priority_countries),
72
- options, value
73
- ), html_options
74
- )
75
- end
76
- end
77
-
78
- class FormBuilder
79
- def country_select(method, priority_countries = nil, options = {}, html_options = {})
80
- @template.country_select(@object_name, method, priority_countries, options.merge(:object => @object), html_options)
81
- end
82
- end
83
- end
84
- end
@@ -1 +0,0 @@
1
- # Uninstall hook code here