add ability to specify checked and uncked values for boolean input #651

Merged
merged 2 commits into from Sep 5, 2012

Conversation

Projects
None yet
4 participants
Collaborator

nashby commented Aug 26, 2012

I'll update README if this will be merged.
closes #643

This pull request passes (merged 77de2778 into 46d4bb4).

Collaborator

rafaelfranca commented Aug 26, 2012

👍

Collaborator

nashby commented Aug 26, 2012

I think we should wait for @carlosantoniodasilva thoughts about this feature as he wasn't sure about it in #643.

Collaborator

rafaelfranca commented Aug 26, 2012

Sure.

@carlosantoniodasilva carlosantoniodasilva commented on the diff Sep 4, 2012

test/inputs/boolean_input_test.rb
@@ -14,6 +14,18 @@ class BooleanInputTest < ActionView::TestCase
assert_no_select 'label'
end
+ test 'input uses custom checked value' do
+ @user.action = 'on'
+ with_input_for @user, :action, :boolean, :checked_value => 'on', :unchecked_value => 'off'
+ assert_select 'input[type=checkbox][value=on][checked=checked]'
+ end
+
+ test 'input uses custom unchecked value' do
+ @user.action = 'off'
+ with_input_for @user, :action, :boolean, :checked_value => 'on', :unchecked_value => 'off'
+ assert_select 'input[type=checkbox][value=on]'
@carlosantoniodasilva

carlosantoniodasilva Sep 4, 2012

Collaborator

That doesn't ensure it's not checked, right? Perhaps it could have another line with assert_no_select 'input[checked]' or something like that? And may need to check if the hidden field is being generated with the correct unchecked_value (same in the other test)?

What do you guys think?

@rafaelfranca

rafaelfranca Sep 4, 2012

Collaborator

Yes, we need to ensure this.

@nashby

nashby Sep 4, 2012

Collaborator

@rafaelfranca @carlosantoniodasilva right, I've just pushed these tests. Please take a look.

Collaborator

carlosantoniodasilva commented Sep 4, 2012

Just added a comment, other than that, looks good, awesome @nashby thanks! 👍

This pull request passes (merged 9503f8e into 4e6508e).

Collaborator

rafaelfranca commented Sep 4, 2012

:shipit:

Collaborator

carlosantoniodasilva commented Sep 5, 2012

Looks good, :shipit:, thanks.

@nashby nashby added a commit that referenced this pull request Sep 5, 2012

@nashby nashby Merge pull request #651 from nashby/fix-issue-643
add ability to specify checked and uncked values for boolean input
ece4dca

@nashby nashby merged commit ece4dca into plataformatec:master Sep 5, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment