Testingv1

Debugging and writing tests.
I didn't run this code, but if it doesn't work, this is much closer to what you want:

```ruby
class User < ActiveRecord::Base
  has_many :kitchens
  has_many :pending_reservations, through: :kitchens

  def pending_reservation_count
    pending_reservations.count
  end
end

class Kitchen < ActiveRecord::Base
  # See my answer on Quora for what's going on below:
  #   http://bit.ly/1q5gKCF
  has_many :pending_reservations,
           class_name: 'Reservation',
           where: Reservation.pending.where_values_hash

end

class Reservation < ActiveRecord::Base
  # The Reservation class and ONLY the Reservation class should know
  # what it means to be "pending" at the database level.  Everything
  # else should use this scope to answer that question.
  scope :pending, lambda { where(state: 'pending') }
end
```

Then, if you want the pending reservation count for a user, just run

```ruby
current_user.pending_reservation_count
```