diff --git a/CHANGELOG.md b/CHANGELOG.md
index 05327c847..923ceef97 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ Bugfixes:
Features:
- Your contribution here!
+ * [#325](https://github.com/bootstrap-ruby/rails-bootstrap-forms/pull/325): Support :prepend and :append for the `select` helper - [@donv](https://github.com/donv).
+
## [2.7.0][] (2017-04-21)
diff --git a/README.md b/README.md
index 26afb6d58..0e1226246 100644
--- a/README.md
+++ b/README.md
@@ -55,13 +55,13 @@ This generates the following HTML:
-
+
-
+
```
@@ -209,7 +209,7 @@ This automatically adds the `has-feedback` class to the `form-group`:
```html
-
+
@@ -227,7 +227,7 @@ You can also prepend and append buttons. Note: The buttons must contain the
`btn` class to generate the correct markup.
```erb
-<%= f.text_field :search, append: link_to("Go", "#", class: "btn btn-default") %>
+<%= f.text_field :search, append: link_to("Go", "#", class: "btn btn-secondary") %>
```
To add a class to the input group wrapper, use `:input_group_class` option.
@@ -249,7 +249,7 @@ Which produces the following output:
```erb
-
+
```
@@ -330,7 +330,7 @@ Here's the output:
```html
-
+
test@email.com
@@ -355,7 +355,7 @@ this defining these selects as `inline-block` and a width of `auto`.
### Submit Buttons
-The `btn btn-default` css classes are automatically added to your submit
+The `btn btn-secondary` css classes are automatically added to your submit
buttons.
```erb
@@ -468,10 +468,10 @@ error will be displayed below the field. Rails normally wraps the fields in a
div (field_with_errors), but this behavior is suppressed. Here's an example:
```html
-
-
+
+
- can't be blank
+ can't be blank
```
diff --git a/lib/bootstrap_form/form_builder.rb b/lib/bootstrap_form/form_builder.rb
index e127c7bb3..423360e6e 100644
--- a/lib/bootstrap_form/form_builder.rb
+++ b/lib/bootstrap_form/form_builder.rb
@@ -115,6 +115,7 @@ def time_zone_select_with_bootstrap(method, priority_zones = nil, options = {},
def check_box_with_bootstrap(name, options = {}, checked_value = "1", unchecked_value = "0", &block)
options = options.symbolize_keys!
check_box_options = options.except(:label, :label_class, :help, :inline)
+ check_box_options[:class] = ["form-check-input", check_box_options[:class]].compact.join(' ')
html = check_box_without_bootstrap(name, check_box_options, checked_value, unchecked_value)
label_content = block_given? ? capture(&block) : options[:label]
@@ -134,10 +135,10 @@ def check_box_with_bootstrap(name, options = {}, checked_value = "1", unchecked_
if options[:inline]
label_class = " #{label_class}" if label_class
- label(label_name, html, class: "checkbox-inline#{disabled_class}#{label_class}")
+ label(label_name, html, class: "form-check-inline#{disabled_class}#{label_class}")
else
- content_tag(:div, class: "checkbox#{disabled_class}") do
- label(label_name, html, class: label_class)
+ content_tag(:div, class: "form-check#{disabled_class}") do
+ label(label_name, html, class: ["form-check-label", label_class].compact.join(" "))
end
end
end
@@ -198,6 +199,7 @@ def form_group(*args, &block)
name = args.first
options[:class] = ["form-group", options[:class]].compact.join(' ')
+ options[:class] << " row" if get_group_layout(options[:layout]) == :horizontal
options[:class] << " #{error_class}" if has_error?(name)
options[:class] << " #{feedback_class}" if options[:icon]
@@ -263,11 +265,11 @@ def control_class
end
def label_class
- "control-label"
+ "form-control-label"
end
def error_class
- "has-error"
+ "has-danger"
end
def feedback_class
@@ -313,6 +315,7 @@ def form_group_builder(method, options, html_options = nil)
css_options = html_options || options
control_classes = css_options.delete(:control_class) { control_class }
css_options[:class] = [control_classes, css_options[:class]].compact.join(" ")
+ css_options[:class] << " form-control-danger" if has_error?(method)
options = convert_form_tag_options(method, options) if acts_like_form_tag
@@ -389,12 +392,16 @@ def generate_label(id, name, options, custom_label_col, group_layout)
end
def generate_help(name, help_text)
- help_text = get_error_messages(name) if has_error?(name) && inline_errors
- return if help_text === false
+ if has_error?(name) && inline_errors
+ help_text = get_error_messages(name)
+ help_klass = 'form-control-feedback'
+ end
+ return if help_text == false
+ help_klass ||= 'form-text text-muted'
help_text ||= get_help_text_by_i18n_key(name)
- content_tag(:span, help_text, class: 'help-block') if help_text.present?
+ content_tag(:span, help_text, class: help_klass) if help_text.present?
end
def generate_icon(icon)
diff --git a/lib/bootstrap_form/helper.rb b/lib/bootstrap_form/helper.rb
index ee73c9016..6788588e8 100644
--- a/lib/bootstrap_form/helper.rb
+++ b/lib/bootstrap_form/helper.rb
@@ -10,15 +10,8 @@ def bootstrap_form_for(object, options = {}, &block)
options[:html] ||= {}
options[:html][:role] ||= 'form'
- layout = case options[:layout]
- when :inline
- "form-inline"
- when :horizontal
- "form-horizontal"
- end
-
- if layout
- options[:html][:class] = [options[:html][:class], layout].compact.join(" ")
+ if options[:layout] == :inline
+ options[:html][:class] = [options[:html][:class], "form-inline"].compact.join(" ")
end
temporarily_disable_field_error_proc do
diff --git a/lib/bootstrap_form/helpers/bootstrap.rb b/lib/bootstrap_form/helpers/bootstrap.rb
index 988b16280..58b31d76e 100644
--- a/lib/bootstrap_form/helpers/bootstrap.rb
+++ b/lib/bootstrap_form/helpers/bootstrap.rb
@@ -2,7 +2,7 @@ module BootstrapForm
module Helpers
module Bootstrap
def submit(name = nil, options = {})
- options.reverse_merge! class: 'btn btn-default'
+ options.reverse_merge! class: 'btn btn-secondary'
super(name, options)
end
diff --git a/test/bootstrap_checkbox_test.rb b/test/bootstrap_checkbox_test.rb
index 0d2832690..da2df251c 100644
--- a/test/bootstrap_checkbox_test.rb
+++ b/test/bootstrap_checkbox_test.rb
@@ -8,74 +8,74 @@ def setup
end
test "check_box is wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms')
end
test "disabled check_box has proper wrapper classes" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms', disabled: true)
end
test "check_box label allows html" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.check_box(:terms, label: %{I agree to the terms}.html_safe)
end
test "check_box accepts a block to define the label" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.check_box(:terms) { "I agree to the terms" }
end
test "check_box accepts a custom label class" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.check_box(:terms, label_class: 'btn')
end
test "check_box responds to checked_value and unchecked_value arguments" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms'}, 'yes', 'no')
end
test "inline checkboxes" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms', inline: true)
end
test "disabled inline check_box" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms', inline: true, disabled: true)
end
test "inline checkboxes with custom label class" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.check_box(:terms, inline: true, label_class: 'btn')
end
test 'collection_check_boxes renders the form_group correctly' do
collection = [Address.new(id: 1, street: 'Foobar')]
- expected = %{
With a help!
}
+ expected = %{
With a help!
}
assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, label: 'This is a checkbox collection', help: 'With a help!')
end
test 'collection_check_boxes renders multiple checkboxes correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{
}
+ expected = %{
}
assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street)
end
test 'collection_check_boxes renders inline checkboxes correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, inline: true)
end
test 'collection_check_boxes renders with checked option correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{
}
assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, lambda { |a| "address_#{a.id}" }, :street, checked: ["address_1", "address_2"])
assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, lambda { |a| "address_#{a.id}" }, :street, checked: collection)
diff --git a/test/bootstrap_fields_test.rb b/test/bootstrap_fields_test.rb
index 3eaec8ece..b7d9445c9 100644
--- a/test/bootstrap_fields_test.rb
+++ b/test/bootstrap_fields_test.rb
@@ -8,32 +8,32 @@ def setup
end
test "color fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.color_field(:misc)
end
test "date fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.date_field(:misc)
end
test "date time fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.datetime_field(:misc)
end
test "date time local fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.datetime_local_field(:misc)
end
test "email fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.email_field(:misc)
end
test "file fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.file_field(:misc)
end
@@ -43,58 +43,58 @@ def setup
end
test "month local fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.month_field(:misc)
end
test "number fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.number_field(:misc)
end
test "password fields are wrapped correctly" do
- expected = %{
A good password should be at least six characters long
}
+ expected = %{
A good password should be at least six characters long
}
assert_equivalent_xml expected, @builder.password_field(:password)
end
test "phone/telephone fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.phone_field(:misc)
assert_equivalent_xml expected, @builder.telephone_field(:misc)
end
test "range fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.range_field(:misc)
end
test "search fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.search_field(:misc)
end
test "text areas are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.text_area(:comments)
end
test "text fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.text_field(:email)
end
test "time fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.time_field(:misc)
end
test "url fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.url_field(:misc)
end
test "week fields are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.week_field(:misc)
end
@@ -107,7 +107,7 @@ def setup
end
end
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, output
end
@@ -120,7 +120,7 @@ def setup
end
end
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, output
end
@@ -133,7 +133,7 @@ def setup
end
end
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, output
end
@@ -146,7 +146,7 @@ def setup
end
end
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, output
end
end
diff --git a/test/bootstrap_form_group_test.rb b/test/bootstrap_form_group_test.rb
index 26a0a62fb..6c1f6d115 100644
--- a/test/bootstrap_form_group_test.rb
+++ b/test/bootstrap_form_group_test.rb
@@ -8,32 +8,32 @@ def setup
end
test "changing the label text via the label option parameter" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.text_field(:email, label: 'Email Address')
end
test "changing the label text via the html_options label hash" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.text_field(:email, label: {text: 'Email Address'})
end
test "hiding a label" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.text_field(:email, hide_label: true)
end
test "adding a custom label class via the label_class parameter" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.text_field(:email, label_class: 'btn')
end
test "adding a custom label class via the html_options label hash" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.text_field(:email, label: {class: 'btn'})
end
test "adding a custom label and changing the label text via the html_options label hash" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.text_field(:email, label: {class: 'btn', text: "Email Address"})
end
@@ -43,51 +43,51 @@ def setup
end
test "preventing a label from having the required class" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.text_field(:email, skip_required: true)
end
test "adding prepend text" do
- expected = %{
@
}
+ expected = %{
@
}
assert_equivalent_xml expected, @builder.text_field(:email, prepend: '@')
end
test "adding append text" do
- expected = %{
.00
}
+ expected = %{
.00
}
assert_equivalent_xml expected, @builder.text_field(:email, append: '.00')
end
test "append and prepend button" do
- prefix = %{
}
after_button = prefix + field + button + suffix
before_button = prefix + button + field + suffix
both_button = prefix + button + field + button + suffix
- button_src = link_to("Click", "#", class: "btn btn-default")
+ button_src = link_to("Click", "#", class: "btn btn-secondary")
assert_equivalent_xml after_button, @builder.text_field(:email, append: button_src)
assert_equivalent_xml before_button, @builder.text_field(:email, prepend: button_src)
assert_equivalent_xml both_button, @builder.text_field(:email, append: button_src, prepend: button_src)
end
test "adding both prepend and append text" do
- expected = %{
$.00
}
+ expected = %{
$.00
}
assert_equivalent_xml expected, @builder.text_field(:email, prepend: '$', append: '.00')
end
test "help messages for default forms" do
- expected = %{
This is required
}
+ expected = %{
This is required
}
assert_equivalent_xml expected, @builder.text_field(:email, help: 'This is required')
end
test "help messages for horizontal forms" do
- expected = %{
This is required
}
+ expected = %{
This is required
}
assert_equivalent_xml expected, @horizontal_builder.text_field(:email, help: "This is required")
end
test "help messages to look up I18n automatically" do
- expected = %{
A good password should be at least six characters long
}
+ expected = %{
A good password should be at least six characters long
}
assert_equivalent_xml expected, @builder.text_field(:password)
end
@@ -110,7 +110,7 @@ def setup
end
test "help messages to ignore translation when user disables help" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.text_field(:password, help: false)
end
@@ -119,7 +119,7 @@ def setup
%{
}
assert_equivalent_xml expected, output
end
test ":input_group_class should apply to input-group" do
- expected = %{
}
+ expected = %{
}
assert_equivalent_xml expected, @builder.email_field(:email, append: @builder.primary('Subscribe'), input_group_class: 'input-group-lg')
end
end
diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb
index e4df02c60..7e0d69683 100644
--- a/test/bootstrap_form_test.rb
+++ b/test/bootstrap_form_test.rb
@@ -18,12 +18,12 @@ def setup
end
test "horizontal-style forms" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email }
end
test "existing styles aren't clobbered when specifying a form style" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal, html: { class: "my-style" }) { |f| f.email_field :email }
end
@@ -33,20 +33,20 @@ def setup
end
test "bootstrap_form_tag acts like a form tag" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, bootstrap_form_tag(url: '/users') { |f| f.text_field :email, label: "Your Email" }
end
test "bootstrap_form_tag does not clobber custom options" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, bootstrap_form_tag(url: '/users') { |f| f.text_field :email, name: 'NAME', id: "ID" }
end
test "bootstrap_form_tag allows an empty name for checkboxes" do
checkbox = if ::Rails::VERSION::STRING >= '5.1'
- %{}
+ %{}
else
- %{}
+ %{}
end
expected = %{}
assert_equivalent_xml expected, bootstrap_form_tag(url: '/users') { |f| f.check_box :misc }
@@ -56,7 +56,7 @@ def setup
@user.email = nil
@user.valid?
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true) { |f| f.text_field :email }
end
@@ -64,7 +64,7 @@ def setup
@user.email = nil
@user.valid?
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true, inline_errors: true) { |f| f.text_field :email }
end
@@ -74,7 +74,7 @@ def setup
@user.email = nil
@user.valid?
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true, inline_errors: true) { |f| f.text_field :email }
I18n.backend.store_translations(:en, {activerecord: {attributes: {user: {email: nil}}}})
@@ -147,17 +147,17 @@ def setup
end
test "custom label width for horizontal forms" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, label_col: 'col-sm-1' }
end
test "offset for form group without label respects label width for horizontal forms" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal, label_col: 'col-md-2', control_col: 'col-md-10') { |f| f.form_group { f.submit } }
end
test "custom input width for horizontal forms" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, control_col: 'col-sm-5' }
end
@@ -169,7 +169,7 @@ def setup
f.text_field(:email, help: 'This is required')
end
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, output
end
@@ -181,7 +181,7 @@ def setup
f.text_field(:email, help: 'This is required')
end
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, output
end
@@ -193,13 +193,13 @@ def setup
f.text_field(:email, help: 'This is required')
end
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, output
end
test "allows the form object to be nil" do
builder = BootstrapForm::FormBuilder.new :other_model, nil, self, {}
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, builder.text_field(:email)
end
diff --git a/test/bootstrap_other_components_test.rb b/test/bootstrap_other_components_test.rb
index f175c94ed..0933c56f2 100644
--- a/test/bootstrap_other_components_test.rb
+++ b/test/bootstrap_other_components_test.rb
@@ -10,7 +10,7 @@ def setup
test "static control" do
output = @horizontal_builder.static_control :email
- expected = %{
steve@example.com
}
+ expected = %{
steve@example.com
}
assert_equivalent_xml expected, output
end
@@ -19,7 +19,7 @@ def setup
"this is a test"
end
- expected = %{
this is a test
}
+ expected = %{
this is a test
}
assert_equivalent_xml expected, output
end
@@ -28,7 +28,7 @@ def setup
"Custom Control"
end
- expected = %{
Custom Control
}
+ expected = %{
Custom Control
}
assert_equivalent_xml expected, output
end
@@ -37,8 +37,8 @@ def setup
"this is a test"
end
- expected = %{
this is a test
}
- assert_equal expected, output
+ expected = %{
this is a test
}
+ assert_equivalent_xml expected, output
end
test "custom control doesn't require an actual attribute" do
@@ -46,8 +46,8 @@ def setup
"this is a test"
end
- expected = %{
this is a test
}
- assert_equal expected, output
+ expected = %{
this is a test
}
+ assert_equivalent_xml expected, output
end
test "custom control doesn't require a name" do
@@ -55,17 +55,17 @@ def setup
"Custom Control"
end
- expected = %{
Custom Control
}
- assert_equal expected, output
+ expected = %{
Custom Control
}
+ assert_equivalent_xml expected, output
end
test "submit button defaults to rails action name" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.submit
end
test "submit button uses default button classes" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.submit("Submit Form")
end
diff --git a/test/bootstrap_radio_button_test.rb b/test/bootstrap_radio_button_test.rb
index b420c1e01..2ba720da1 100644
--- a/test/bootstrap_radio_button_test.rb
+++ b/test/bootstrap_radio_button_test.rb
@@ -39,84 +39,84 @@ def setup
test 'collection_radio_buttons renders the form_group correctly' do
collection = [Address.new(id: 1, street: 'Foobar')]
- expected = %{
With a help!
}
+ expected = %{
With a help!
}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street, label: 'This is a radio button collection', help: 'With a help!')
end
test 'collection_radio_buttons renders multiple radios correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{
}
+ expected = %{
}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street)
end
test 'collection_radio_buttons renders inline radios correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street, inline: true)
end
test 'collection_radio_buttons renders with checked option correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{
}
+ expected = %{
}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street, checked: 1)
end
test 'collection_radio_buttons renders label defined by Proc correctly' do
collection = [Address.new(id: 1, street: 'Foobar')]
- expected = %{
With a help!
}
+ expected = %{
With a help!
}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, Proc.new { |a| a.street.reverse }, label: 'This is a radio button collection', help: 'With a help!')
end
test 'collection_radio_buttons renders value defined by Proc correctly' do
collection = [Address.new(id: 1, street: 'Foobar')]
- expected = %{
With a help!
}
+ expected = %{
With a help!
}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street, label: 'This is a radio button collection', help: 'With a help!')
end
test 'collection_radio_buttons renders multiple radios with label defined by Proc correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{
}
+ expected = %{
}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, Proc.new { |a| a.street.reverse })
end
test 'collection_radio_buttons renders multiple radios with value defined by Proc correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{
}
+ expected = %{
}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street)
end
test 'collection_radio_buttons renders label defined by lambda correctly' do
collection = [Address.new(id: 1, street: 'Foobar')]
- expected = %{
With a help!
}
+ expected = %{
With a help!
}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, lambda { |a| a.street.reverse }, label: 'This is a radio button collection', help: 'With a help!')
end
test 'collection_radio_buttons renders value defined by lambda correctly' do
collection = [Address.new(id: 1, street: 'Foobar')]
- expected = %{
With a help!
}
+ expected = %{
With a help!
}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, lambda { |a| "address_#{a.id}" }, :street, label: 'This is a radio button collection', help: 'With a help!')
end
test 'collection_radio_buttons renders multiple radios with label defined by lambda correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{
}
+ expected = %{
}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, lambda { |a| a.street.reverse })
end
test 'collection_radio_buttons renders multiple radios with value defined by lambda correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{
}
+ expected = %{
}
assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, lambda { |a| "address_#{a.id}" }, :street)
end
diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb
index 872dfb46e..f934fdd4b 100644
--- a/test/bootstrap_selects_test.rb
+++ b/test/bootstrap_selects_test.rb
@@ -8,34 +8,34 @@ def setup
end
test "time zone selects are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.time_zone_select(:misc)
end
test "selects are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]])
end
test "bootstrap_specific options are handled correctly" do
- expected = %{
Help!
}
+ expected = %{
Help!
}
assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], label: "My Status Label", help: "Help!" )
end
test "selects with options are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], prompt: "Please Select")
end
test "selects with both options and html_options are wrapped correctly" do
- expected = %{}
+ expected = %{}
assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], { prompt: "Please Select" }, class: "my-select")
end
test 'selects with addons are wrapped correctly' do
expected = <<-HTML.strip_heredoc