spree/spree — Issue #935: Preference system returns nil for false boolean
Author: r3ap3r2004
Created: 2012-01-03 09:59:15+00:00
State: open

Latest Edge Code

The preferences system seems to have a bug when returning the value for a boolean when that boolean is set to FALSE.

For example. Setting the Authorize.net payment gateway 'test_mode' boolean to true returns 'true', but setting it to false returns nil.

Steps to test:
1) Add the Authorize.net gateway (note: You don't need to use this gateway, it just provides a known boolean value to use to reproduce the issue.)
2) Set the gateway to operate in Test Mode by clicking on the check box.
3) Go to the rails console and do the following:

```
ruby-1.9.2-head :028 > pm = Spree::PaymentMethod.where(:type => 'Spree::Gateway::AuthorizeNet').first
=> REMOVED THE OUTPUT FOR CLARITY
ruby-1.9.2-head :033 > pm.has_preference?('test_mode')
=> true
ruby-1.9.2-head :030 > pm.get_preference('test_mode')
=> true
ruby-1.9.2-head :031 > pm.set_preference('test_mode', false)
ruby-1.9.2-head :032 > pm.get_preference('test_mode')
=> nil
```

I believe this is a bug. The output when the value is set to false should be 'false' not nil.

For the payment gateways this doesn't seem to matter. But for my module I need an actual false value returned, not a nil.