Skip to content

Commit

Permalink
Merge 42a4d4c into c7f907c
Browse files Browse the repository at this point in the history
  • Loading branch information
RocKhalil authored Dec 2, 2021
2 parents c7f907c + 42a4d4c commit 851f510
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/rails_admin/main/_form_boolean.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% if field.nullable? %>
<div class="btn-group" data-toggle="buttons">
<% {'1': true, '0': false, '': nil}.each do |text, value| %>
<label class="<%= [field.css_classes[value], ("active" if field.form_value == value)] %> btn btn-default">
<label class="<%= [field.css_classes[value], ("active" if field.form_value == value)].compact.join(' ') %> btn btn-default">
<%= form.radio_button field.method_name, text, field.html_attributes.reverse_merge({ checked: field.form_value == value, required: field.required}) %>
<%= field.labels[value].html_safe %>
</label>
Expand Down
11 changes: 11 additions & 0 deletions spec/integration/fields/boolean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,25 @@

it 'can be updated' do
visit edit_path(model_name: 'field_test', id: field_test.id)

# change the value to true and assert the values
find('.boolean_type .fa-check').sibling('input').click
click_button 'Save and edit'
# validate that the success button rendered and is active
expect(page).to have_selector('.boolean_type .success.active')
# validate the value is true
expect(field_test.reload.boolean_field).to be true

# change the value to false and assert the values
find('.boolean_type .fa-times').sibling('input').click
click_button 'Save and edit'
expect(page).to have_selector('.boolean_type .danger.active')
expect(field_test.reload.boolean_field).to be false

# change the value to nil and assert the values
find('.boolean_type .fa-minus').sibling('input').click
click_button 'Save and edit'
expect(page).to have_selector('.boolean_type .default.active')
expect(field_test.reload.boolean_field).to be nil
end
end
Expand Down

0 comments on commit 851f510

Please sign in to comment.