<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/controllers/donations_controller.rb</filename>
    </added>
    <added>
      <filename>db/migrate/20080923234949_add_money_fields_to_donation.rb</filename>
    </added>
    <added>
      <filename>spec/controllers/donations_controller_spec.rb</filename>
    </added>
    <added>
      <filename>spec/controllers/donations_routing_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,5 +3,8 @@ class Donation &lt; ActiveRecord::Base
   belongs_to :pitch
   validates_presence_of :pitch_id
   validates_presence_of :user_id
+  validates_presence_of :amount_in_cents
+
+  named_scope :unpaid, :conditions =&gt; &quot;not paid&quot;
 end
 </diff>
      <filename>app/models/donation.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,6 +17,8 @@
 
 require 'digest/sha1'
 class User &lt; ActiveRecord::Base
+  has_many :donations
+
   # Virtual attribute for the unencrypted password
   attr_accessor :password
 </diff>
      <filename>app/models/user.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@ ActionController::Routing::Routes.draw do |map|
 
   map.root :controller =&gt; 'homes', :action =&gt; 'show'
 
+  map.resources :donations
   map.resources :pitches
   map.resources :profiles
 </diff>
      <filename>config/routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 module AuthenticatedTestHelper
   # Sets the current user in the session from the user fixtures.
   def login_as(user)
-    @request.session[:user_id] = user ? user : nil
+    @request.session[:user_id] = user ? user.id : nil
   end
 
   def authorize_as(user)</diff>
      <filename>lib/authenticated_test_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,6 +31,7 @@ end
 Factory.define :donation do |donation|
   donation.association(:user)
   donation.association(:pitch)
+  donation.amount_in_cents 4200
 end
 
 Factory.define :tip do |tip|</diff>
      <filename>spec/factories.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,11 +3,30 @@ require File.dirname(__FILE__) + '/../spec_helper'
 describe Donation do
   table_has_columns(Donation, :integer, &quot;user_id&quot;)
   table_has_columns(Donation, :integer, &quot;pitch_id&quot;)
+  table_has_columns(Donation, :integer, &quot;amount_in_cents&quot;)
+  table_has_columns(Donation, :boolean, &quot;paid&quot;)
 
   requires_presence_of Donation, :user_id
   requires_presence_of Donation, :pitch_id
+  requires_presence_of Donation, :amount_in_cents
 
   it { Factory(:donation).should belong_to(:user) }
   it { Factory(:donation).should belong_to(:pitch) }
+
+  describe &quot;Donation.unpaid&quot; do
+    before(:each) do
+      Factory(:donation, :paid =&gt; true)
+      Factory(:donation, :paid =&gt; false)
+      @donations = Donation.unpaid
+    end
+
+    it &quot;should not return paid donations&quot; do
+      @donations.select(&amp;:paid?).should be_empty
+    end
+
+    it &quot;should return all unpaid donations&quot; do
+      @donations.reject(&amp;:paid?).should_not be_empty
+    end
+  end
 end
 </diff>
      <filename>spec/models/donation_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,10 @@ require File.dirname(__FILE__) + '/../spec_helper'
 include AuthenticatedTestHelper
 
 describe User do
+  it do
+    Factory(:user).should have_many(:donations)
+  end
+
   describe &quot;signup notification emails&quot; do
     it &quot;sends on create&quot; do
       user = Factory.build(:user)</diff>
      <filename>spec/models/user_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,7 +28,7 @@ end
 def table_has_columns(clazz, type, *column_names)
   column_names.each do |column_name|
     column = clazz.columns.select {|c| c.name == column_name.to_s}.first
-    it &quot;has a string named #{column_name}&quot; do
+    it &quot;has a #{type} named #{column_name}&quot; do
       column.should_not be_nil
       column.type.should == type.to_sym
     end
@@ -60,3 +60,4 @@ def requires_presence_of(clazz, field)
     record.errors.on(field.to_sym).should_not be_nil
   end
 end
+</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>098104a4dc464d969b5fe17bee13528b14d6e8b8</id>
    </parent>
  </parents>
  <author>
    <name>Jon Larkowski</name>
    <email>jonlarkowski@gmail.com</email>
  </author>
  <url>http://github.com/spot-us/spot-us/commit/0f28c041354c62ce7f21c1ba75e11484be2f7dc0</url>
  <id>0f28c041354c62ce7f21c1ba75e11484be2f7dc0</id>
  <committed-date>2008-09-23T18:09:08-07:00</committed-date>
  <authored-date>2008-09-23T18:08:56-07:00</authored-date>
  <message>Added donations controller and user.donations (+tsaleh)</message>
  <tree>1d6f45082c831b0521d7879b49fdf0549862efde</tree>
  <committer>
    <name>Jon Larkowski</name>
    <email>jonlarkowski@gmail.com</email>
  </committer>
</commit>
