lyang/braintree-rails — pull request #5 by n0nick (2013-04-03 08:10:29+00:00)
Title: CreditCard update inconsistent when updating expiration_date

It seems that when trying to update a `CreditCard` instance using the `expiration_date` field, leaving out `expiration_month` and `expiration_year`, i.e.

```ruby
card.update_attributes(:number => '4111111111111111', :cvv => '666', :expiration_date => '12/2027')
```

the behaviour is inconsistent: The first time it is done on a `CreditCard` instance, the change is not registered. After that, it seems to work fine.
See testcase gist: https://gist.github.com/n0nick/5299333

In my debugging efforts, I've concluded that this is related to `lib/braintree_rails/credit_card.rb:57`:

```ruby
attributes.delete(:expiration_date) if expiration_month.present?
```

The trouble is, `expiration_month` is always present for `CreditCard`s that were fetched from Braintree! And so, `expiration_date` gets deleted.

I've included a unit test that expects `expiration_date` to be pending an update, and thus failing for now.
I wasn't sure how to go about actually fixing the bug, since this seems like more of a design decision.