public
Description: Ruby on Rails Budgeting
Homepage: http://activebudget.org
Clone URL: git://github.com/jmckible/activebudget.git
Wire up register.
jmckible (author)
Sat Oct 11 20:27:58 -0700 2008
commit  f6a40c4b15b885bcbe1ebac4eecc4565086d3b0f
tree    bacc629f13c9ce08e726b8d9cb50f6c3dd61a2dd
parent  dc72b5f1d59b739b350fa07535d5e336b44f37df
...
24
25
26
27
 
28
29
30
...
24
25
26
 
27
28
29
30
0
@@ -24,7 +24,7 @@ class ItemsController < ApplicationController
0
   def update
0
     @item = current_user.items.find(params[:id])
0
     @item.update_attributes params[:item]
0
- redirect_to items_path
0
+ redirect_to request.env['HTTP_REFERER'] || items_path
0
   end
0
 
0
   # DELETE /items/:id
...
1
2
3
 
4
5
6
7
8
9
10
 
 
11
12
13
14
 
15
16
...
1
2
 
3
4
5
6
7
8
 
 
9
10
11
12
13
14
15
16
17
0
@@ -1,16 +1,17 @@
0
 class RegisterController < ApplicationController
0
   
0
- # GET /register/2007/1
0
+ # GET /register/:year/:month
0
   # POST /register?&date[year]=2007&date[month]=1
0
   def index
0
     if request.method == :post
0
       year = params[:date][:year].to_i
0
       month = params[:date][:month].to_i
0
- start = Date.new(year, month, 1)
0
- ending = Date.civil(year, month, -1)
0
+ start = Date.new year, month, 1
0
+ ending = Date.civil year, month, -1
0
       @period = start..ending
0
     else
0
       period_assign_whole_month
0
     end
0
+ @items = current_user.items.during @period
0
   end
0
 end
...
23
24
25
26
 
 
 
27
28
29
...
23
24
25
 
26
27
28
29
30
31
0
@@ -23,7 +23,9 @@ class Item < ActiveRecord::Base
0
   #####################################################################
0
   # S C O P E #
0
   #####################################################################
0
- named_scope :on, lambda { |date| {:conditions=>{:date=>date}} }
0
+ named_scope :during, lambda { |date| {:conditions=>{:date=>date}} }
0
+ named_scope :on, lambda { |date| {:conditions=>{:date=>date}} }
0
+
0
   
0
   #####################################################################
0
   # O B J E C T M E T H O D S #
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
...
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
0
@@ -1 +1,29 @@
0
-require File.dirname(__FILE__) + '/../spec_helper'
0
\ No newline at end of file
0
+require File.dirname(__FILE__) + '/../spec_helper'
0
+
0
+describe RegisterController do
0
+
0
+ it 'handles /register with GET' do
0
+ login_as :jordan
0
+ get :index
0
+ assigns(:period).first.should == Date.new(Date.today.year, Date.today.month, 1)
0
+ assigns(:period).last.should == Date.civil(Date.today.year, Date.today.month, -1)
0
+ response.should be_success
0
+ end
0
+
0
+ it 'handles /register/2007/1 with GET' do
0
+ login_as :jordan
0
+ get :index, :year=>2007, :month=>1
0
+ assigns(:period).first.should == Date.new(2007, 1, 1)
0
+ assigns(:period).last.should == Date.civil(2007, 1, 31)
0
+ response.should be_success
0
+ end
0
+
0
+ it 'handles /register with POST' do
0
+ login_as :jordan
0
+ post :index, :date=>{:year=>2008, :month=>10}
0
+ assigns(:period).first.should == Date.new(2008, 10, 1)
0
+ assigns(:period).last.should == Date.civil(2008, 10, 31)
0
+ response.should be_success
0
+ end
0
+
0
+end
0
\ No newline at end of file

Comments

    No one has commented yet.